Skip to content

Conversation

@tejlmand
Copy link

Depends on: zephyrproject-rtos#41301 (has been squashed as first commit, please ignore)

This commit removes the multi-image stage2 bootloader from the Zephyr
image and instead create a dedicated board specific sample for the
stage2 bootloader.

It reuses the Zephyr build infrastructure, such as Zephyr modules,
toolchain, Kconfig, etc. but not the Zephyr kernel itself.

Signed-off-by: Torsten Rasmussen Torsten.Rasmussen@nordicsemi.no


@yonsch feel free to give feedback and cherry-pick / squash as you like into zephyrproject-rtos#34835.

This PR allows to build the stage2 bootloader using standard tools, like cmake + ninja / make or west build, for example:

$ west build -brpi_pico samples/boards/rpi_pico/boot_stage2/ -p -- west build: making build dir /projects/github/ncs/zephyr/build pristine -- west build: generating a build system Loading Zephyr module(s) (Zephyr base): extensions;west;root;zephyr_module;boards;shields;arch;build_configuration;host-tools;generic_toolchain;kconfig;soc;target_toolchain -- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter -- Cache files will be written to: /home/tejlmand/.cache/zephyr -- Found west (found suitable version "0.12.0", minimum required is "0.7.1") -- Board: rpi_pico -- Found dtc: /usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6") -- Found toolchain: zephyr 0.13.1 (/opt/zephyr-sdk-0.13.1) Parsing /projects/github/ncs/zephyr/Kconfig Loaded configuration '/projects/github/ncs/zephyr/boards/arm/rpi_pico/rpi_pico_defconfig' Merged configuration '/projects/github/ncs/zephyr/samples/boards/rpi_pico/boot_stage2/prj.conf' Configuration saved to '/projects/github/ncs/zephyr/build/zephyr/.config' Kconfig header saved to '/projects/github/ncs/zephyr/build/zephyr/include/generated/autoconf.h' -- The C compiler identification is GNU 10.3.0 -- The CXX compiler identification is GNU 10.3.0 -- The ASM compiler identification is GNU -- Found assembler: /opt/zephyr-sdk-0.13.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -- Configuring done -- Generating done -- Build files have been written to: /projects/github/ncs/zephyr/build -- west build: building application [3/3] Generating boot_stage2.bin 
Added HAL module for the Raspberry Pi Pico. Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
Added basic support for the RP2040 SoC. Support includes booting and starting the kernel, on one core only. Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com> Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Added a pinctrl driver for the Raspberry Pi Pico series Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
Added a serial driver for the RP2040. Only polling API is supported. Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
Added GPIO support for the RP2040 SoC. Only one core is supported. Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
Added support for Raspberry Pi's Pico board, using the RP2040 SoC. Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
This is a squash of zephyrproject-rtos#41301 and is not intended for review in this PR. However, this PR is dependent of the work from zephyrproject-rtos#41301. Ignore this commit is this PR. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit removes the multi-image stage2 bootloader from the Zephyr image and instead create a dedicated board specific sample for the stage2 bootloader. It reuses the Zephyr build infrastructure, such as Zephyr modules, toolchain, Kconfig, etc. but not the Zephyr kernel itself. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
@tejlmand tejlmand force-pushed the review/34835_bootloader_stage2_review branch from f8f9209 to d69d1e7 Compare January 20, 2022 22:44
@tejlmand
Copy link
Author

Note: this PR just presents the outline, one thing that should be considered is whether the complete kconfig tree should be available in this sample.

In principle it doesn't make sense to have the whole tree, but kept cleaning up this part outside.

Would like some feedback on the approach seen from your viewpoint first.

@rivimey
Copy link

rivimey commented Jan 21, 2022

One comment: this work is basically not board specific and there are at least 3 more boards in the queue waiting to be added** which will need the same cmake files at least. Can the new code be moved under the 'soc' tree instead, where it can be shared nicely?

2 from adafruit, one solderparty; there are many others out there.

@tejlmand
Copy link
Author

One comment:

Thanks a lot.
I answered here, to make it easier for others to chip in.

@yonsch yonsch force-pushed the support_raspberrypi_pico branch from 2e9c80f to a69989e Compare January 22, 2022 17:53
@tejlmand tejlmand requested a review from yonsch as a January 22, 2022 17:53
@yonsch yonsch force-pushed the support_raspberrypi_pico branch 12 times, most recently from e441781 to c93f206 Compare February 2, 2022 11:33
@tejlmand tejlmand closed this Feb 10, 2022
@tejlmand tejlmand deleted the review/34835_bootloader_stage2_review branch February 10, 2022 16:10
yonsch pushed a commit that referenced this pull request Dec 8, 2022
This patch reworks how fragments are handled in the net_buf infrastructure. In particular, it removes the union around the node and frags members in the main net_buf structure. This is done so that both can be used at the same time, at a cost of 4 bytes per net_buf instance. This implies that the layout of net_buf instances changes whenever being inserted into a queue (fifo or lifo) or a linked list (slist). Until now, this is what happened when enqueueing a net_buf with frags in a queue or linked list: 1.1 Before enqueueing: +--------+ +--------+ +--------+ |#1 node|\ |#2 node|\ |#3 node|\ | | \ | | \ | | \ | frags |------| frags |------| frags |------NULL +--------+ +--------+ +--------+ net_buf #1 has 2 fragments, net_bufs #2 and #3. Both the node and frags pointers (they are the same, since they are unioned) point to the next fragment. 1.2 After enqueueing: +--------+ +--------+ +--------+ +--------+ +--------+ |q/slist |------|#1 node|------|#2 node|------|#3 node|------|q/slist | |node | | *flag | / | *flag | / | | / |node | | | | frags |/ | frags |/ | frags |/ | | +--------+ +--------+ +--------+ +--------+ +--------+ When enqueing a net_buf (in this case #1) that contains fragments, the current net_buf implementation actually enqueues all the fragments (in this case #2 and #3) as actual queue/slist items, since node and frags are one and the same in memory. This makes the enqueuing operation expensive and it makes it impossible to atomically dequeue. The `*flag` notation here means that the `flags` member has been set to `NET_BUF_FRAGS` in order to be able to reconstruct the frags pointers when dequeuing. After this patch, the layout changes considerably: 2.1 Before enqueueing: +--------+ +--------+ +--------+ |#1 node|--NULL |#2 node|--NULL |#3 node|--NULL | | | | | | | frags |-------| frags |-------| frags |------NULL +--------+ +--------+ +--------+ This is very similar to 1.1, except that now node and frags are different pointers, so node is just set to NULL. 2.2 After enqueueing: +--------+ +--------+ +--------+ |q/slist |-------|#1 node|-------|q/slist | |node | | | |node | | | | frags | | | +--------+ +--------+ +--------+ | +--------+ +--------+ | |#2 node|--NULL |#3 node|--NULL | | | | | +------------| frags |-------| frags |------NULL +--------+ +--------+ When enqueuing net_buf #1, now we only enqueue that very item, instead of enqueing the frags as well, since now node and frags are separate pointers. This simplifies the operation and makes it atomic. Resolves zephyrproject-rtos#52718. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants