diff --git a/_targets/armv7m4/stm32l4x6/build.project b/_targets/armv7m4/stm32l4x6/build.project index b9fc9504..25711d38 100644 --- a/_targets/armv7m4/stm32l4x6/build.project +++ b/_targets/armv7m4/stm32l4x6/build.project @@ -33,57 +33,22 @@ export PORTS_CURL=n # # Platform dependent parameters # -SIZE_PAGE=$((0x200)) -PAGE_MASK=$((0xfffffe00)) +export SIZE_PAGE=$((0x200)) # # Project specific build # -BOOT_DEVICE="flash0" -NAME_USER_SCRIPT="user.plo" -OFFS_USER_SCRIPT=$((0xc800)) -MAGIC_USER_SCRIPT=$((0xdabaabad)) -KERNEL_OFFS=$((0xd000)) +export BOOT_DEVICE="flash0" +export MAGIC_USER_SCRIPT=dabaabad # Physical kernel address KERNEL_PHBASE=$((0x08000000)) # flash0 start address -KERNEL_PHOFFS=$KERNEL_OFFS -export KERNEL_PHADDR=$(printf "%08x" $(($KERNEL_PHBASE + KERNEL_PHOFFS))) - -# All data/code maps need to be cacheable to allow unaligned accesses - -# Pre-init script is launched before user script -PREINIT_SCRIPT=( - "map flash0 0x08000000 0x08080000 rxcb" - "map flash1 0x08080000 0x08100000 rxcb" - "map ram 0x20000000 0x20050000 rwxcb" - "map io 0x40000000 0x60000000 rw" - "map otp 0x1fff0000 0x20000000 rw" - "phfs flash0 2.0 raw" - "phfs flash1 2.1 raw" - "phfs ramdev 4.0 raw" - "console 0.1") - - -# Production user script contains applications to run Phoenix-RTOS -USER_SCRIPT=( - "kernelimg ${BOOT_DEVICE}" - "app ${BOOT_DEVICE} -x stm32l4-multi flash0 ram;io;otp" - "app ${BOOT_DEVICE} -x psh flash0 ram" - "wait 2000" - "go!") - - -# Example of user dev script which call remotely script -DEV_USER_SCRIPT=( - "echo on" - "wait 3000") - - -REMOTE_USER_SCRIPT=("5a5aa5a5") +KERNEL_PHOFFS=$(image_builder.py query --nvm "$NVM_CONFIG" '{{ nvm.flash0.kernel.offs }}') +KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS))) +export KERNEL_PHADDR b_build_project() { @@ -96,16 +61,20 @@ b_build_target() { b_log "Building $TARGET project" b_log "Building phoenix-rtos-loader" - b_mkscript_preinit + image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script.plo + RAM_SCRIPT=1 image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script-ram.plo make -C plo all + + b_log "Creating kernel binary image" + KERNEL_ELF="phoenix-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.elf" + ${CROSS}objcopy "${PREFIX_PROG_STRIPPED}${KERNEL_ELF}" -O binary "${PREFIX_PROG_STRIPPED}${KERNEL_ELF/.elf/.bin}" } b_image_target() { - b_mkscript_user "${USER_SCRIPT[@]}" - b_prod_image - b_dev_image + image_builder.py -v partition --nvm "$NVM_CONFIG" --name user --script "$PLO_SCRIPT_USER" + image_builder.py -v disk --nvm "$NVM_CONFIG" --name flash0 --part "plo=${PREFIX_PROG_STRIPPED}plo-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.img" --out "phoenix.disk" } b_test_target() { diff --git a/_targets/armv7m4/stm32l4x6/nvm.yaml b/_targets/armv7m4/stm32l4x6/nvm.yaml new file mode 100644 index 00000000..d5ccad81 --- /dev/null +++ b/_targets/armv7m4/stm32l4x6/nvm.yaml @@ -0,0 +1,16 @@ +flash0: + # internal flash - 2 banks 512 kB - assume the target image can't exceed one bank + size: 0x80000 # 512 kB + block_size: 0x100 # program page size + padding_byte: 0xff + partitions: + - name: plo + offs: 0x0 + - name: user + offs: 0xc800 + # if size not set - last non-virtual partition will be extnded to the end of flash + + # virtual offset [user.offs] + [user.script.size] + - name: kernel + offs: 0xd000 + virtual: True diff --git a/_targets/armv7m4/stm32l4x6/preinit.plo.yaml b/_targets/armv7m4/stm32l4x6/preinit.plo.yaml new file mode 100644 index 00000000..0273f2e8 --- /dev/null +++ b/_targets/armv7m4/stm32l4x6/preinit.plo.yaml @@ -0,0 +1,23 @@ +size: 0x200 +is_relative: False + +contents: + # NOTE: All data/code maps need to be cacheable to allow unaligned accesses + # env.BOOT_DEVICE should correspond to one of the map names + - map flash0 0x08000000 0x08080000 rxcb + - map flash1 0x08080000 0x08100000 rxcb + - map ram 0x20000000 0x20050000 rwxcb + - map io 0x40000000 0x60000000 rw + - map otp 0x1fff0000 0x20000000 rw + - phfs flash0 2.0 raw + - phfs flash1 2.1 raw + - phfs ramdev 4.0 raw + - console 0.1 + - if: '{{ not(env.RAM_SCRIPT) | default(false) }}' + action: call + set_base: True + device: '{{ env.BOOT_DEVICE }}' + filename: user.plo + offset: '{{ nvm[env.BOOT_DEVICE].user.offs }}' + target_magic: '{{ env.MAGIC_USER_SCRIPT }}' + diff --git a/_targets/armv7m4/stm32l4x6/user.plo.yaml b/_targets/armv7m4/stm32l4x6/user.plo.yaml new file mode 100644 index 00000000..0b3523c5 --- /dev/null +++ b/_targets/armv7m4/stm32l4x6/user.plo.yaml @@ -0,0 +1,11 @@ +# kernel + initrd +magic: '{{ env.MAGIC_USER_SCRIPT }}' +size: '{{ nvm.flash0.kernel.offs - nvm.flash0.user.offs }}' # 0x800 but ensure we're consistent with NVM config +is_relative: True + +contents: + - kernelimg {{ env.BOOT_DEVICE }} + - app {{ env.BOOT_DEVICE }} -x stm32l4-multi {{ env.BOOT_DEVICE }} ram;io;otp + - app {{ env.BOOT_DEVICE }} -x psh {{ env.BOOT_DEVICE }} ram + - wait 2000 + - go!