Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Select Git revision
Loading items
Show changes
Commits on Source (5)
Showing
with 4396 additions and 9007 deletions
......@@ -2,6 +2,7 @@
#include "card10-version.h"
#include "card10.h"
#include "card10-platform.h"
#include "led.h"
#include "pb.h"
#include "pmic.h"
......@@ -29,6 +30,11 @@
#define PARTITION_START (0x10000000 + 64 * 1024)
#define PARTITION_END (0x10000000 + 1024 * 1024 - 1)
struct bootloader_version __attribute__((section(".bootloader_version"))) __bootloader_version = {
.magic = BOOTLOADER_MAGIC,
.version = BOOTLOADER_VERSION,
};
DIR dir;
FATFS FatFs;
......@@ -68,6 +74,18 @@ int mount(void)
return 0;
}
int get_msc_flag(void)
{
// We use the API call memory to store a magic value there.
uint32_t* flag = API_CALL_MEM_ADDRESS;
if (*flag == MSC_MAGIC) {
*flag = 0;
return 1;
} else {
return 0;
}
}
int check_integrity(void)
{
FIL file;
......@@ -242,8 +260,8 @@ int main(void)
bootloader_display_init();
// If the button is pressed, we go into MSC mode.
if (PB_Get(3)) {
// If the button is pressed or a flag in memory is detected, we go into MSC mode.
if (PB_Get(3) || get_msc_flag()) {
msc();
}
......
......@@ -13,7 +13,7 @@ splash_screen = custom_target(
],
)
executable(
elf = executable(
name + '.elf',
'main.c',
'mscmem.c',
......@@ -24,6 +24,7 @@ executable(
version_hdr,
dependencies: [
libcard10,
libcard10_platform,
max32665_startup_boot,
libff13,
maxusb,
......@@ -39,3 +40,11 @@ build_image = [files('./build_image.sh'), python3]
# build_multi_image.sh
build_multi_image = [files('./build_multi_image.sh'), python3]
bootloader_bin = custom_target(
name + '.bin',
build_by_default: true,
output: name + '.bin',
input: elf,
command: [build_image, '@INPUT@', '@OUTPUT0@'],
)
......@@ -6,7 +6,9 @@ RUN set -e -x ;\
apt-get install -y \
git \
gcc-arm-none-eabi \
python3-pip ;\
python3-pip \
xxd \
jq ;\
apt-get install -y -t stretch-backports \
meson ;\
pip3 install crc16 pillow ;\
......
......@@ -8,7 +8,9 @@ RUN set -e -x ;\
git \
libclang-dev \
llvm \
python3-pip ;\
python3-pip \
xxd \
jq ;\
pip3 install \
clang \
sphinx \
......
#pragma once
#include "epicardium.h"
#include "card10-platform.h"
#include <stdint.h>
#include <stdbool.h>
......@@ -49,6 +50,4 @@ struct api_call_mem {
uint8_t buffer[1];
};
/* TODO: Make this address part of the linker script */
static __attribute__((unused)) struct api_call_mem* API_CALL_MEM =
(struct api_call_mem*)0x20080000;
static __attribute__((unused)) struct api_call_mem* API_CALL_MEM = API_CALL_MEM_ADDRESS;
Source diff could not be displayed: it is too large. Options to address this: view the blob.
#include "card10.h"
#include "bootloader.h"
#include "card10-platform.h"
#include "modules/log.h"
#include "epicardium.h"
#include "flc.h"
#include "icc.h"
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
extern char _isr_vector_end;
extern char _text;
void update_bootloader(void)
{
/* Look at the first symbol after the ISV in the bootloader image. */
struct bootloader_version* VERSION_STRUCT =
(struct bootloader_version*)(0x10000000 + (&_isr_vector_end - &_text));
uint32_t current_version =
(VERSION_STRUCT->magic == BOOTLOADER_MAGIC)
? VERSION_STRUCT->version
: 0;
LOG_DEBUG("startup", "Current bootloader version: %lu", current_version);
if (current_version == BOOTLOADER_VERSION) {
return;
}
epic_disp_print(0, 5, "bl update", 0xffff, 0x0000);
epic_disp_print(0, 24, "version " TOSTRING(BOOTLOADER_VERSION), 0xffff, 0x0000);
epic_disp_update();
ICC_Disable();
LOG_INFO("startup", "Erasing old bootloader");
int ret = FLC_MultiPageErase(0x10000000, 0x10000000 + 1024 * 64 - 1);
if (ret != E_NO_ERROR) {
LOG_DEBUG("startup", "FLC_MultiPageErase failed with %d", ret);
epic_disp_print(0, 45, "failed", 0xffff, 0x0000);
epic_disp_update();
while (1);
}
LOG_INFO("startup", "Updating bootloader to version %u", BOOTLOADER_VERSION);
ret = FLC_Write(
0x10000000,
bootloader_bootloader_bin_len,
(uint32_t *)bootloader_bootloader_bin
);
if (ret != E_NO_ERROR) {
LOG_DEBUG("startup", "FLC_Write failed with %d", ret);
epic_disp_print(0, 45, "failed", 0xffff, 0x0000);
epic_disp_update();
while (1);
}
ICC_Enable();
LOG_INFO("startup", "Bootloader update finished");
card10_reset();
}
#ifndef BOOTLOADER_UPDATE_H
#define BOOTLOADER_UPDATE_H
void update_bootloader(void);
#endif
......@@ -242,7 +242,7 @@ API(API_SYSTEM_EXEC, int __epic_exec(char *name));
/**
* Reset/Restart card10
*/
API(API_SYSTEM_RESET, void epic_system_reset(void));
API(API_SYSTEM_RESET, void epic_system_reset(int to_bootloader));
/**
* PMIC API
......
......@@ -2,6 +2,7 @@
#include "modules/log.h"
#include "modules/filesystem.h"
#include "card10-version.h"
#include "bootloader_update.h"
#include "FreeRTOS.h"
#include "task.h"
......@@ -20,6 +21,8 @@ int main(void)
LOG_DEBUG("startup", "Initializing hardware ...");
hardware_early_init();
update_bootloader();
/*
* Version Splash
*/
......
......@@ -24,13 +24,13 @@ api_caller_lib = static_library(
'api/caller.c',
'api/interrupt-receiver.c',
api[0], # Caller
dependencies: periphdriver,
dependencies: [periphdriver, libcard10_platform],
)
api_caller = declare_dependency(
include_directories: include_directories('.'),
link_with: api_caller_lib,
dependencies: periphdriver,
dependencies: [periphdriver, libcard10_platform],
)
api_dispatcher_lib = static_library(
......@@ -39,7 +39,7 @@ api_dispatcher_lib = static_library(
'api/interrupt-sender.c',
'api/control.c',
api[1], # Dispatcher
dependencies: [libcard10, periphdriver],
dependencies: [libcard10, libcard10_platform, periphdriver],
)
##########################################################################
......@@ -83,12 +83,13 @@ elf = executable(
'cdcacm.c',
'main.c',
'support.c',
'bootloader_update.c',
'fs/filesystem_fat.c',
module_sources,
l0der_sources,
ble_sources,
version_hdr,
dependencies: [libcard10, max32665_startup_core0, maxusb, libff13, ble, bhy1],
dependencies: [libcard10, libcard10_platform, max32665_startup_core0, maxusb, libff13, ble, bhy1],
link_with: [api_dispatcher_lib, freertos],
link_whole: [max32665_startup_core0_lib, board_card10_lib, newlib_heap_lib],
include_directories: [freertos_includes],
......
......@@ -6,6 +6,7 @@
#include "l0der/l0der.h"
#include "card10.h"
#include "card10-platform.h"
#include "FreeRTOS.h"
#include "task.h"
......@@ -17,6 +18,7 @@
#define PYCARDIUM_IVT (void *)0x10080000
#define BLOCK_WAIT pdMS_TO_TICKS(1000)
/*
* Loading an empty filename into Pycardium will drop straight into the
* interpreter. This define is used to make it more clear when we intend
......@@ -282,8 +284,12 @@ static void load_menu(bool reset)
/*
* Restart the firmware
*/
void epic_system_reset(void)
void epic_system_reset(int to_bootloader)
{
// Set a flag for the bootloader.
uint32_t* flag = API_CALL_MEM_ADDRESS;
*flag = to_bootloader ? MSC_MAGIC : 0;
card10_reset();
}
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -4,7 +4,7 @@
/***** Includes *****/
#include "card10.h"
#include "bootloader-9251ea6.h"
#include "bootloader.h"
#include "display.h"
#include "gfx.h"
#include "pmic.h"
......@@ -59,8 +59,8 @@ int main(void)
ret = FLC_Write(
0x10000000,
sizeof(bootloader_data),
(uint32_t *)bootloader_data
bootloader_bootloader_bin_len,
(uint32_t *)bootloader_bootloader_bin
);
if (ret != E_NO_ERROR) {
printf("FLC_Write failed with %d\n", ret);
......
name = 'bootloader-update'
header = custom_target(
'bootloader.h',
output: 'bootloader.h',
input: bootloader_bin,
command: [xxd, '-i', '@INPUT@', '@OUTPUT0@'],
)
header_dep = declare_dependency(
sources: [header],
)
elf = executable(
name + '.elf',
'main.c',
dependencies: [libcard10, max32665_startup],
dependencies: [libcard10, max32665_startup, header_dep],
link_whole: [max32665_startup_lib, board_card10_lib],
link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
......
#ifndef CARD10_PLATFORM_H
#define CARD10_PLATFORM_H
#define MSC_MAGIC 0x6E697807
#define BOOTLOADER_MAGIC 0xBADC0FFE
#define BOOTLOADER_VERSION 1
/* TODO: Make this address part of the linker script */
#define API_CALL_MEM_ADDRESS ((void*)0x20080000)
/* Bootloader version struct. */
struct bootloader_version {
uint32_t magic;
uint32_t version;
};
#endif
includes = include_directories(
'./',
)
libcard10_platform = declare_dependency(
include_directories: includes,
)
......@@ -12,5 +12,6 @@ subdir('./FreeRTOS-Plus/')
subdir('./micropython/')
subdir('./card10/')
subdir('./card10-platform/')
subdir('./mx25lba/')
subdir('./ff13/')
......@@ -48,6 +48,7 @@ SECTIONS {
{
_text = .;
KEEP(*(.isr_vector))
KEEP(*(.bootloader_version))
*(.text*) /* program code */
*(.rodata*) /* read-only data: "const" */
......