-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
nrf: Split mpconfigport.h into multiple files. #6246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
One of the main driver for this change is #5472 where i would like to set |
For stm32 I created a |
After looking it a second time, i see that it is quite similar to what i would like to achieve. I believe i'm calling it I could do it a bit like I'm believe i cannot make up my mind on my own here. However, I also believe similarities between ports should come first. Let me shuffle it a bit around. |
f5a38d1
to
3636eeb
Compare
@dpgeorge , It looks to me that stm32 |
I like your first, original commit. It's pretty clean and clear what it's doing. So I'd suggest go with just that, except maybe remove |
Updated the PR with two new commits for a fair comparison. I updated original proposal and also enabled the 3 feature configs to show how it might look. It could probably be optimized to elide the |
Ok, this latest version looks pretty good to me. |
ports/nrf/mpconfigdevice_nrf51822.h
Outdated
// Board overridable feature configuration. | ||
|
||
#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN | ||
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (!defined(BLUETOOTH_SD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not allowed to use defined
within a #define
; instead do:
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (!BLUETOOTH_SD)
or, if the symbolBLUETOOTH_SD
is not guaranteed to be defined, probably it should be:
#if defined(BLUETOOTH_SD)
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
#else
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not allowed to use defined within a #define
I did some tests here, and apparently it looks like it does work. Could it be because BLUETOOTH_SD
is passed through the compiler as a CFLAG
?
However, i get a few 12 extra bytes in the compilation when using (!defined(BLUETOOTH_SD))
compared to just set 0 or 1. I cross checked also thatLTO and DEBUG has no impact on this. It would have looked cleaner doing a single line. I guess, until i can explain those 12 extra bytes, it is more safe to do what you suggest here, doing the second variant as BLUETOOTH_SD might not be present.
I'll post the results here in case it might be worth something (I also cross checked with pca10056, and it is similar compilations).
make BOARD=microbit
mpconfigdevice_nrf51822.h:
#define MICROPY_PY_UBINASCII (!defined(BLUETOOTH_SD))
LINK build-microbit/firmware.elf
text data bss dec hex filename
142220 100 1156 143476 23074 build-microbit/firmware.elf
firmware.map:
0x000000000001d67c mp_module_ubinascii
mpconfigdevice_nrf51822.h:
#define MICROPY_PY_UBINASCII (1)
LINK build-microbit/firmware.elf
text data bss dec hex filename
142232 100 1156 143488 23080 build-microbit/firmware.elf
firmware.map:
0x000000000001d67c mp_module_ubinascii
mpconfigdevice_nrf51822.h:
#define MICROPY_PY_UBINASCII (0)
LINK build-microbit/firmware.elf
text data bss dec hex filename
141264 100 1156 142520 22cb8 build-microbit/firmware.elf
firmware.map: Symbol mp_module_ubinascii not found
make BOARD=microbit SD=s110
mpconfigdevice_nrf51822.h:
#define MICROPY_PY_UBINASCII (!defined(BLUETOOTH_SD))
LINK build-microbit-s110/firmware.elf
text data bss dec hex filename
149088 100 1300 150488 24bd8 build-microbit-s110/firmware.elf
firmware.map: Symbol mp_module_ubinascii not found
#define MICROPY_PY_UBINASCII (1)
LINK build-microbit-s110/firmware.elf
text data bss dec hex filename
150048 100 1300 151448 24f98 build-microbit-s110/firmware.elf
firmware.map:
0x0000000000036a00 mp_module_ubinascii
mpconfigdevice_nrf51822.h:
#define MICROPY_PY_UBINASCII (0)
LINK build-microbit-s110/firmware.elf
text data bss dec hex filename
149100 100 1300 150500 24be4 build-microbit-s110/firmware.elf
firmware.map: Symbol mp_module_ubinascii not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some tests here, and apparently it looks like it does work
It could just be gcc that allows it. I'm pretty sure it's invalid code by the C standard and clang or other compilers will reject it. Might not be an issue for the nrf port with arm-none-eabi-gcc
but IMO better to avoid this pattern.
However, i get a few 12 extra bytes in the compilation when using
(!defined(BLUETOOTH_SD))
compared to just set 0 or 1
From the output above it looks like the 12 extra bytes are there when using 0/1 (ie the opposite of your statement).... and that could be just because the git repo is dirty and it adds the -dirty
string to the REPL banner, which increases code size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the output above it looks like the 12 extra bytes are there when using 0/1 (ie the opposite of your statement).... and that could be just because the git repo is dirty and it adds the -dirty string to the REPL banner, which increases code size.
Yeah, that makes sense! Thanks! I had forgot about the appended string. The count also indicates this.
Splitting mpconfigport.h into multiple device specific files in order to facilitate variations between devices. Due to the fact that the devices might have variations in features and also variations in flash size it makes sense that some devices offers more functionality than others without being limited by restricted devices. For example more micropython features can be activated for nrf52840 with 1MB flash, compared to nrf51 with 256KB.
Enabling the following features for all targets, except for nrf51 targets compiled to be used with SoftDevice: - MICROPY_PY_ARRAY_SLICE_ASSIGN - MICROPY_PY_SYS_STDFILES - MICROPY_PY_UBINASCII
c555c77
to
33add63
Compare
Removed development commits. I guess the PR is now what i would like to get in. Edit: removed "more or less" :) |
Looks good! |
Don't reset GPIO4 on the MagTag (used for voltage monitoring)
Splitting mpconfigport.h into multiple device specific
files in order to facilitate variations between devices.
Due to the fact that the devices might have variations in
features and also variations in flash size it makes sense
that some devices offers more functionality than others
without being limited by restricted devices.
For example more micropython features can be activated for
nrf52840 with 1MB flash, compared to nrf51 with 256KB.