Skip to content

boards: arm: Adjust xiao_ble for default bootloader.#1

Closed
petejohanson wants to merge 0 commit intomniestroj:boards-xiao-blefrom
petejohanson:xiao_ble_uf2
Closed

boards: arm: Adjust xiao_ble for default bootloader.#1
petejohanson wants to merge 0 commit intomniestroj:boards-xiao-blefrom
petejohanson:xiao_ble_uf2

Conversation

@petejohanson
Copy link

Adjust the flash partitions for default Adafruit nRF52
Bootloader, enable UF2 build by default, and document
how to flash UF2 images to the device.

Signed-off-by: Peter Johanson peter@peterjohanson.com

Copy link
Owner

@mniestroj mniestroj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try it yet, but some early feedback.

Comment on lines 89 to 97
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition! Tough

Flashing
========

section now needs to be either nested under

External Debugger
=================

or rephrased or something. It is misleading to have UF2 Flashing and Flashing at the same level, as it is now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, I changed both Flashing and Debugging to be nested one level deeper. That work for you?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

can use an External Debug Probe to program the board. If you have one, you can
also use an external :ref:`debug probe <debug-probes>` to flash and debug
Zephyr applications, but you need to solder an SWD header onto the back side of
the board.
Copy link

@ghost ghost Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you wanna mention the expansion board here? https://wiki.seeedstudio.com/Seeeduino-XIAO-Expansion-Board/

That's what i'm using. it's got pogo pins that match the bottom 4 pins. It does work for me, but there's not a wiring tutorial yet. I'm using an nrf51 dk to do the flashing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have one, but that might be a good idea. @mniestroj thoughts? I can add here, or you can add yourself.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is a good idea to mention expansion board. Personally for some reason I thought that the expansion board is not compatible with XIAO BLE series.

Copy link

@ghost ghost Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says on the page that the expansion board is not supported, but there are no reasons given. I asked in their discord, and i couldn't get an answer there either. They do say it will be supported, but also no timeline or mention of the mechanism.

However, I'm able to use the onboard OLED display with an arduino demo sketch and flash the device with jlink/nrfjprog via the pogo pins.

I need to try again, but I'm pretty sure I was able to use it with a battery as well.

So I guess what i'm saying is that they say it doesn't work, but it is definitely useful for a fair amount of things.

boot_partition: partition@f4000 {
label = "adafruit_boot";
reg = <0x000f4000 0x0000c000>;
};
Copy link

@ghost ghost Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this support both the mcuboot way and the original bootloader? I"m not that familiar with this aspect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not with the exact same board DTS, that I know of. Usually if you wanted to override something like that, you'd add a board specific overlay file to your application and then update the DTS w/ the correct partitions.

I don't believe Zephyr supports multiple partition "tables" in the DTS, that I've seen/been able to find.

Copy link

@ghost ghost Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. i was hoping you could use chosen nodes for this to pick different default. The default adafruit bootloader and one more aligned with mcuboot. I won't be getting to this aspect of my program for a bit longer, so i'm not that familiar with this part. Maybe that's all wrong.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are certainly chosen nodes for the code region, slots, etc, but I couldn't find a chosen node to select the whole set of partitions.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there is no such mechanism yet. I think there was some thread on some PR to create something similar, but that never got upstreamed AFAIK.

@mniestroj
Copy link
Owner

@petejohanson I've tested this PR. Looks like there were some whitespace issues in DTS (checkpatch was complaining about) and also CONFIG_USE_DT_CODE_PARTITION=y was missing in xiao_ble_defconfig file. Fixed both issues, added you as co-author and force-pushed the original Zephyr PR. Ohh, and mentioned Expansion Board as suggested by @jrobeson .

@petejohanson
Copy link
Author

Ah, indeed. Sorry for missing that. Thanks for integrating!

mniestroj pushed a commit that referenced this pull request Dec 7, 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|\     |zephyrproject-rtos#2  node|\     |zephyrproject-rtos#3  node|\
 |        | \    |        | \    |        | \
 | frags  |------| frags  |------| frags  |------NULL
 +--------+      +--------+      +--------+

net_buf #1 has 2 fragments, net_bufs zephyrproject-rtos#2 and zephyrproject-rtos#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|------|zephyrproject-rtos#2  node|------|zephyrproject-rtos#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 zephyrproject-rtos#2 and zephyrproject-rtos#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 |zephyrproject-rtos#2  node|--NULL |zephyrproject-rtos#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  |       |        |
 +--------+       +--------+       +--------+
                      |            +--------+       +--------+
                      |            |zephyrproject-rtos#2  node|--NULL |zephyrproject-rtos#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

2 participants