Skip to content

esp32/machine_rtc: Allow MEM_USER_MAXLEN to be changed during compile. Fixes #4973 #4974

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

Closed
wants to merge 1 commit into from

Conversation

nevercast
Copy link
Contributor

Don't define MEM_USER_MAXLEN if it already exists, i.e. may have been defined on the command line as C arguments.

Fixes: #4973

@nevercast
Copy link
Contributor Author

nevercast commented Aug 5, 2019

I will be setting this from my cmodule like so:

CFLAGS_USERMOD += -DMEM_USER_MAXLEN=0

@nevercast
Copy link
Contributor Author

I have just verified that this patch fixes my issue. By using the CFLAGS_USERMOD line above in my cmodule Makefile. Once this PR is merged, I can start building from upstream again.

@andrewleech
Copy link
Contributor

andrewleech commented Aug 6, 2019

I mostly work with the stm32 port, where there's lots of this kind of #ifdef for overriding during build, so the concept should be fine.

Most of the build defines there though follow a common pattern like MICROPYTHON_PY_XYZ, as seen in https://github.com/micropython/micropython/blob/master/ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.h for example.

I'm not sure if this pattern (or similar) is also common in esp port, but I'd suggest it's good to follow either way to highlight the fact this is intended and a build variable (with hard coded default).

@nevercast
Copy link
Contributor Author

nevercast commented Aug 6, 2019

Hi @andrewleech

I don't see anything called mpconfigboard.h. For the ESP32 we do use an sdkconfig file which essentially sets up the underlying system on the ESP32 image. I suspect its similar.

I do like the idea of having a common place to configure MicroPython for each port, and we do have mpconfigport.h which is probably the most similar thing we have. We just don't have different configs for different boards (other than those with and without external PSRAM, which the sdkconfig handles).

I'm happy to move some defaults to elsewhere, but for the moment I don't think there is a home for this sort of thing on the ESP32 port. It would also still need to be an #ifndef because I'm trying to make zero changes to MicroPython repository when building, so I need to declare the variable as a C_FLAG.

@mattytrentini
Copy link
Contributor

ESP32 doesn't currently have the concept of a board like STM32; the mpconfigboard.h is akin to the mpconfigport.h but for board-level configuration.

I've started looking in to extending the ESP32 port to handle boards; it would make sense given the glut of different boards that have appeared. Could use some help though because my first priority was bringing that concept to the ESP8266 (primarily to make it easy for a beginner to start with the popular Wemos boards and their distinct "Dx" naming of pins).

@andrewleech
Copy link
Contributor

Sorry my intention when linking to that file wasn't so much meaning to use a board config file, but just an example of #define naming conventions.

Still, I'm not sure if that convention is used elsewhere on the esp ports, but I think it's a good idea for consistency nonetheless.

@nevercast
Copy link
Contributor Author

nevercast commented Aug 7, 2019

I was talking to @zrecore this morning regarding his D2WD board issues. You're right @mattytrentini that with the increase in ESP32 boards I'd like to see an approach to having board configs. Similar to the way stm32 port is handling it. We have a board directory. We should have subfolders for board configurations/community boards with their own sdkconfig, defines, and partition.csv so that when someone wants to compile uPy for a board they have purchased from Tindie or wherever, they can just make BOARD=tinypico and it builds as recommend

@nevercast
Copy link
Contributor Author

nevercast commented Aug 11, 2019

@jimmo Is there anyway to achieve this with your changes in #4991 ? I'd really like my small change to land in master but if I can achieve the same with your changes, I'll do that and either rebase on top of what you have, or just wait for that to land and create a new PR.

Seems like the typical thing is to have vars prefered with MICROPY_ and they should be set somewhere before build, probably in a board Makefile. So I guess it would be better to follow convention and change the name of this variable. I'll do that.

@jimmo
Copy link
Member

jimmo commented Aug 12, 2019

@nevercast Yes, this is exactly the intention of #4991. You would set this variable in boards/BOARD/mpconfigboard.h (not the makefile).

Note: the convention seems to be to name it MICROPY_HW_, and generally you don't see port-specific (e.g. _ESP32_) parts. I'd call it MICROPY_HW_RTC_USER_MEM_MAX.

@nevercast
Copy link
Contributor Author

I see, _HW_ is anything that is port specific?

@nevercast
Copy link
Contributor Author

Rebased and applied recommendations. Is it worth adding any documentation regarding this? Or a board config to demonstrate that this can be configured in mpconfigboard.h ?

@nevercast
Copy link
Contributor Author

Spoke with @jimmo and he seemed happy with this. Is there anything blocking this being merged, @dpgeorge ?

@nevercast
Copy link
Contributor Author

Can I please get some feedback on this? I am using this feature so I can't use mainline upy. Cheers.

@nevercast
Copy link
Contributor Author

Rebased and squashed. Had to do it at my end anyway so pushed the change upstream.

@nevercast
Copy link
Contributor Author

I will present this pull request better in the future, and add examples or tests.

@nevercast nevercast closed this Sep 13, 2019
@nevercast nevercast deleted the patch-1 branch September 13, 2019 00:11
@dpgeorge
Copy link
Member

Followed up in #5349

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Jul 9, 2021
…i-fixes

Rp2040 audio fixes; disallow ctrl-C interrupts of SPI and PIO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

esp32/machine_rtc: Make it easy to change the RTC UserMem size.
5 participants