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

Add GIGA_M4 variant #740

Closed
wants to merge 1 commit into from
Closed

Add GIGA_M4 variant #740

wants to merge 1 commit into from

Conversation

AndrewCapon
Copy link

There is an issue when using the Giga R1 with Arduino/Platformio Arduino where the incorrect PinNames.h is used.

This is due to it using the Portenta_h7_m4 variant and the use of includes.txt which has incorrect locations for the include files.

This variant solves that issue.

@facchinm
Copy link
Member

Hi @AndrewCapon , I understand the issue but creating a new variant (outside the automated script) is not maintainable. To fix the problem, I'd propose something like

diff --git a/boards.txt b/boards.txt
index 6a067f06..7e792b73 100644
--- a/boards.txt
+++ b/boards.txt
@@ -739,7 +739,7 @@ giga.compiler.mbed.defines={build.variant.path}/defines.txt
 giga.compiler.mbed.ldflags={build.variant.path}/ldflags.txt
 giga.compiler.mbed.cflags={build.variant.path}/cflags.txt
 giga.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt
-giga.compiler.mbed.includes={build.variant.path}/includes.txt
+giga.compiler.mbed.includes={build.variant.path}/../GIGA/includes.txt
 giga.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
 giga.compiler.mbed="{build.variant.path}/libs/libmbed.a"
 giga.vid.0=0x2341

The correctlty picks the right include paths for M4. Can you test this patch and report if it works fine for you?

@AndrewCapon
Copy link
Author

Hi @facchinm

Super, thanks for the info, for the Arduino IDE I will give this a go and get back to you...

Do you by any chance know how you would go about this for using Platformio/Arduino?

Thanks

Andy

@facchinm
Copy link
Member

Platformio should work just fine as long as you compile with arduino:mbed_giga:giga:target_core=cm4,split=75_25 fqbn (you can specify other flash split strategy of course, like 50_50)

@AndrewCapon
Copy link
Author

Hi @facchinm

Sorry to be a little dim but I'm not sure I understand :)

@mjs513
Copy link

mjs513 commented Oct 23, 2023

@AndrewCapon , @facchinm , @KurtE

Just gave @KurtE's pintest sketch a shot that had showed different LED pins between the M7 and M4 cores (see post https://forum.arduino.cc/t/digitalwritefast-for-giga/1180527/7) making your recommended change in the boards.txt file seems to have fixed those pins have done and exhausted test but the day is still young.

M7 Pin Test
------------------------------------
Test Pin by number: LED_BUILTIN(87)
Test Pin by name: LED_RED(140)
Test Pin by name: LED_GREEN(157)
Test Pin by name: LED_BLUE(67)
Test Pin by number: 86(86)
Test Pin by number: 87(87)
Test Pin by number: 88(88)
Test Pin by number: D86(86)
Test Pin by number: D87(87)
Test Pin by number: D88(88)

M4 Pin Test
------------------------------------
Test Pin by number: LED_BUILTIN(87)
Test Pin by name: LED_RED(140)
Test Pin by name: LED_GREEN(157)
Test Pin by name: LED_BLUE(67)
Test Pin by number: 86(86)
Test Pin by number: 87(87)
Test Pin by number: 88(88)
Test Pin by number: D86(86)
Test Pin by number: D87(87)
Test Pin by number: D88(88)

@facchinm
Copy link
Member

No worries 🙂 I don't usually use platformio but in the arduino world you can specify the target using a colon separated list (fqbn). target_core=cm4 is the extra field you need to target the M4 core, so there should be a way in platformio to add that directive and test the right include paths being passed.

@AndrewCapon
Copy link
Author

PlatformIO as far as I can tell does it all a bit different, there is a json file for each board.

Currently the GIGA doesn't have these boards defined and unwisely I took it upon myself to have a go at getting it shoehorned in!

so for instance the board definition for the portenta_h7_m4 is:

{
  "build": {
    "arduino":{
      "ldscript": "linker_script.ld",
      "flash_layout": "50_50"
    },
    "extra_flags": "-DARDUINO_PORTENTA_H7_M4 -DPORTENTA_H7_PINS",
    "core": "arduino",
    "cpu": "cortex-m4",
    "f_cpu": "480000000L",
    "mcu": "stm32h747xih6",
    "variant": "PORTENTA_H7_M4",
    "product_line": "STM32H747xx",
    "hwids": [
      [
        "0x2341",
        "0x035b"
      ]
    ]
  },
  "connectivity": [
    "bluetooth",
    "wifi"
  ],
  "debug": {
    "jlink_device": "STM32H747XI_M4",
    "openocd_target": "stm32h7x_dual_bank"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "Arduino Portenta H7 (M4 core)",
  "upload": {
    "maximum_ram_size": 294248,
    "maximum_size": 1048576,
    "protocol": "dfu",
    "protocols": [
      "cmsis-dap",
      "dfu",
      "jlink",
      "stlink",
      "mbed"
    ],
    "require_upload_port": true,
    "use_1200bps_touch": true,
    "wait_for_upload_port": true,
    "offset_address": "0x08100000"
  },
  "url": "https://www.arduino.cc/pro/hardware/product/portenta-h7",
  "vendor": "Arduino"
}

So the important bit is "variant": "PORTENTA_H7_M4" this is what is linking to the variants here.

So I have added a board definition for the GIGA_M4 but the issue is without a GIGA_M4 Variant defined it all falls apart :)

@KurtE
Copy link

KurtE commented Oct 23, 2023

I also confirmed that worked with Arduino IDE nightly build 20231020

I ran the same test that @mjs513 ran, except I updated it slightly to try other Pin Names and to display a little more...

*** Test Led Pins M4 version ***
Test Pin by number: LED_BUILTIN(87)
Test Pin by name: LED_RED(140 PI_12)
Test Pin by name: LED_GREEN(157 PJ_13)
Test Pin by name: LED_BLUE(67 PE_3)
Test Pin by number: 86(86)
Test Pin by number: 87(87)
Test Pin by number: 88(88)
Test Pin by number: D86(86)
Test Pin by number: D87(87)
Test Pin by number: D88(88)
Test Pin by name: PI_12(140 PI_12)
Test Pin by name: PJ_13(157 PJ_13)
Test Pin by name: PE_3(67 PE_3)

Note: this is my test sketch for my version of digitalWriteFast, digitalToggleFast...
Which is up at: https://github.com/KurtE/UNOR4-stuff/tree/main/libraries/GIGA_digitalWriteFast

Hopefully you can get this into real builds soon! (fix for pin names)

@facchinm
Copy link
Member

Closing since #741 got merged

@facchinm facchinm closed this Nov 13, 2023
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