Skip to content
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

Added to possibility to have extra compiler directives for a board. #713

Merged
merged 59 commits into from
Jul 27, 2022

Conversation

PontusO
Copy link
Contributor

@PontusO PontusO commented Jul 26, 2022

As the title suggests this PR adds functionality for adding an extra compiler -D directive for each board. This adds the possibility to have some control of the compilation phase for libraries that requires different configurations for different platforms.

PontusO and others added 30 commits July 29, 2021 09:53
Merged LTE support class from dev-branch
Fixed spelling error
@maxgerhardt
Copy link
Contributor

maxgerhardt commented Jul 26, 2022

Could you also add this to the PlatformIO board generation logic at

def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flashsizemb, boot2):
json = """{
"build": {
"arduino": {
"earlephilhower": {
"boot2_source": "BOOT2.S",
"usb_vid": "VID",
"usb_pid": "PID"
}
},
"core": "earlephilhower",
"cpu": "cortex-m0plus",
"extra_flags": "-D ARDUINO_BOARDDEFINE -DARDUINO_ARCH_RP2040 -DUSBD_MAX_POWER_MA=USBPWR",
with the build flags being added to extra_flags if present?

And re-execute the script after that.

@JAndrassy
Copy link
Contributor

JAndrassy commented Jul 26, 2022

this would alow only one -D but the build.extra_flags allows any compilator command line parameters, not only -D

example:

mkrwifi1010.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ {build.usb_flags} -DUSE_BQ24195L_PMIC

Comment on lines 125 to 126
if extra != None:
print('%s.build.extra_flags=-D%s' % (name, extra))
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, maybe for future expansion extra should be a list and you can just do for x in extra:.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I'll look into that during the week.

Copy link
Owner

Choose a reason for hiding this comment

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

Note this change should also apply to the JSON creation section below, of course. I'll hold off on this merge until the list addition is in.

Another thing, not related to this PR, @PontusO, is now that there is a network infrastructure, would it make sense to integrate the different network interfaces your boards have to make use of the LWIP/etc.?

For example, on the ESP8266 using the lwip-ethernet class we've added the WizNet boards and an ENC-xxxx wired ethernet board into the LWIP infra so they can use WiFiClient, WiFiClientSecure, etc.

Copy link
Contributor

@JAndrassy JAndrassy Jul 26, 2022

Choose a reason for hiding this comment

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

@earlephilhower that would require some kind of MAC level firmware for esp32.
does this core support w5500 or enc28j60 as network interface?

Copy link
Owner

Choose a reason for hiding this comment

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

that would require some kind of MAC level firmware for esp32

Well, the WiFi negotiation/etc., would definitely be from scratch, but if there is a naked Ethernet packet send/receive option already available it's pretty close to fitting in to the existing lwip-ethernet/CYW43 framework.

does this core support w5500 or enc28j60 as network interface?

It's very close to supporting it. I stole the infrastructure from the ESP8266 where are drivers for those chips, but as usual I hit the code with a hatchet so probably broke some things in a minor way. They won't run with no code changes, but they should go with only minimal ones.

Only so many hours in the day, and right now my focus is on OTA, but importing those is in the queue (esp. since I got a donated W5500 board and have an ENCJ boad hanging around already)...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note this change should also apply to the JSON creation section below, of course. I'll hold off on this merge until the list addition is in.

Another thing, not related to this PR, @PontusO, is now that there is a network infrastructure, would it make sense to integrate the different network interfaces your boards have to make use of the LWIP/etc.?

For example, on the ESP8266 using the lwip-ethernet class we've added the WizNet boards and an ENC-xxxx wired ethernet board into the LWIP infra so they can use WiFiClient, WiFiClientSecure, etc.

@earlephilhower It makes perfect sense to integrate support for our boards into the work you have made. I did some initial investigation and it looks easy enough to get the wifi control stuff in place. Lets discuss what needs to be done.

@earlephilhower
Copy link
Owner

@PontusO are we ready for a merge here? Thx!

@PontusO
Copy link
Contributor Author

PontusO commented Jul 27, 2022

I think so, this allows for a list of macros to be defined. As requested.

@earlephilhower earlephilhower merged commit e6e87fd into earlephilhower:master Jul 27, 2022
@JAndrassy
Copy link
Contributor

how would you enter something like this?

mkrwifi1010.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT {build.usb_flags} -D__SAMD21G18A__

@maxgerhardt
Copy link
Contributor

The -D is forced, so injecting {build.usb_flags} wouldn't be possible with this mehod. But I guess they can add that stuff in platform.txt compile commands directly? Hm.

@JAndrassy
Copy link
Contributor

the {somename} can be a key with a value selected in Tools menu with a menu defined in boards.txt

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.

4 participants