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

Giga: compatibility fixes with M4 builds #741

Merged
merged 10 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ envie_m7.menu.target_core.cm7.build.fpu=-mfpu=fpv5-d16
envie_m7.menu.target_core.cm7.build.architecture=cortex-m7
envie_m7.menu.target_core.cm7.compiler.mbed.arch.define=

envie_m7.menu.target_core.cm4.build.variant=PORTENTA_H7_M4
envie_m7.menu.target_core.cm4.build.variant=GENERIC_STM32H747_M4
envie_m7.menu.target_core.cm4.build.mcu=cortex-m4
envie_m7.menu.target_core.cm4.build.fpu=-mfpu=fpv4-sp-d16
envie_m7.menu.target_core.cm4.build.architecture=cortex-m4
Expand All @@ -99,7 +99,7 @@ envie_m7.compiler.mbed.defines={build.variant.path}/defines.txt
envie_m7.compiler.mbed.ldflags={build.variant.path}/ldflags.txt
envie_m7.compiler.mbed.cflags={build.variant.path}/cflags.txt
envie_m7.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt
envie_m7.compiler.mbed.includes={build.variant.path}/includes.txt
envie_m7.compiler.mbed.includes={build.variant.path}/../PORTENTA_H7_M7/includes.txt
envie_m7.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
envie_m7.compiler.mbed="{build.variant.path}/libs/libmbed.a"
envie_m7.vid.0=0x2341
Expand Down Expand Up @@ -492,7 +492,7 @@ nicla_vision.menu.target_core.cm7.build.fpu=-mfpu=fpv5-d16
nicla_vision.menu.target_core.cm7.build.architecture=cortex-m7
nicla_vision.menu.target_core.cm7.compiler.mbed.arch.define=

nicla_vision.menu.target_core.cm4.build.variant=PORTENTA_H7_M4
nicla_vision.menu.target_core.cm4.build.variant=GENERIC_STM32H747_M4
nicla_vision.menu.target_core.cm4.build.mcu=cortex-m4
nicla_vision.menu.target_core.cm4.build.fpu=-mfpu=fpv4-sp-d16
nicla_vision.menu.target_core.cm4.build.architecture=cortex-m4
Expand All @@ -510,7 +510,7 @@ nicla_vision.compiler.mbed.defines={build.variant.path}/defines.txt
nicla_vision.compiler.mbed.ldflags={build.variant.path}/ldflags.txt
nicla_vision.compiler.mbed.cflags={build.variant.path}/cflags.txt
nicla_vision.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt
nicla_vision.compiler.mbed.includes={build.variant.path}/includes.txt
nicla_vision.compiler.mbed.includes={build.variant.path}/../NICLA_VISION/includes.txt
nicla_vision.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
nicla_vision.compiler.mbed="{build.variant.path}/libs/libmbed.a"
nicla_vision.vid.0=0x2341
Expand Down Expand Up @@ -590,7 +590,7 @@ opta.menu.target_core.cm7.build.fpu=-mfpu=fpv5-d16
opta.menu.target_core.cm7.build.architecture=cortex-m7
opta.menu.target_core.cm7.compiler.mbed.arch.define=

opta.menu.target_core.cm4.build.variant=PORTENTA_H7_M4
opta.menu.target_core.cm4.build.variant=GENERIC_STM32H747_M4
opta.menu.target_core.cm4.build.mcu=cortex-m4
opta.menu.target_core.cm4.build.fpu=-mfpu=fpv4-sp-d16
opta.menu.target_core.cm4.build.architecture=cortex-m4
Expand All @@ -617,7 +617,7 @@ opta.compiler.mbed.defines={build.variant.path}/defines.txt
opta.compiler.mbed.ldflags={build.variant.path}/ldflags.txt
opta.compiler.mbed.cflags={build.variant.path}/cflags.txt
opta.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt
opta.compiler.mbed.includes={build.variant.path}/includes.txt
opta.compiler.mbed.includes={build.variant.path}/../OPTA/includes.txt
opta.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
opta.compiler.mbed="{build.variant.path}/libs/libmbed.a"
opta.vid.0=0x2341
Expand Down Expand Up @@ -716,7 +716,7 @@ giga.menu.target_core.cm7.build.fpu=-mfpu=fpv5-d16
giga.menu.target_core.cm7.build.architecture=cortex-m7
giga.menu.target_core.cm7.compiler.mbed.arch.define=

giga.menu.target_core.cm4.build.variant=PORTENTA_H7_M4
giga.menu.target_core.cm4.build.variant=GENERIC_STM32H747_M4
giga.menu.target_core.cm4.build.mcu=cortex-m4
giga.menu.target_core.cm4.build.fpu=-mfpu=fpv4-sp-d16
giga.menu.target_core.cm4.build.architecture=cortex-m4
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion giga.variables
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export FLAVOUR="giga"
export VARIANTS=("GIGA PORTENTA_H7_M4")
export VARIANTS=("GIGA GENERIC_STM32H747_M4")
export FQBNS=("giga")
export LIBRARIES=("MRI Portenta_SDRAM SPI WiFi ea_malloc openamp_arduino STM32H747_System ThreadDebug Himax_HM01B0 PDM Arduino_H7_Video USBAudio KernelDebug Portenta_Audio RPC USBHID Wire Portenta_lvgl Camera rpclib OV7670 mbed-memory-status Scheduler USBMSD USBMIDI SocketWrapper MCUboot Arduino_CAN")
export BOOTLOADERS=("GIGA")
2 changes: 1 addition & 1 deletion libraries/Arduino_CAN/src/Arduino_CAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* COMPILE TIME CHECKS
**************************************************************************************/

#if !(defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_GIGA))
#if !(defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_GIGA))
# error "CAN only available on Arduino Portenta H7 and Arduino Giga (of all ArduinoCore-mbed enabled boards)."
#endif

Expand Down
6 changes: 3 additions & 3 deletions libraries/Camera/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define ALIGN_PTR(p,a) ((p & (a-1)) ?(((uintptr_t)p + a) & ~(uintptr_t)(a-1)) : p)

// Include all image sensor drivers here.
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
#if defined (ARDUINO_PORTENTA_H7_M7)

#define DCMI_TIM (TIM1)
#define DCMI_TIM_PIN (GPIO_PIN_1)
Expand Down Expand Up @@ -80,7 +80,7 @@ arduino::MbedI2C CameraWire(I2C_SDA1, I2C_SCL1);

// DCMI GPIO pins struct
static const struct { GPIO_TypeDef *port; uint16_t pin; } dcmi_pins[] = {
#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
#if defined (ARDUINO_PORTENTA_H7_M7)
{GPIOA, GPIO_PIN_4 },
{GPIOA, GPIO_PIN_6 },
{GPIOI, GPIO_PIN_4 },
Expand Down Expand Up @@ -175,7 +175,7 @@ void HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi)
hgpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
hgpio.Alternate = GPIO_AF13_DCMI;

#if defined (ARDUINO_PORTENTA_H7_M7) || defined (ARDUINO_PORTENTA_H7_M4)
#if defined (ARDUINO_PORTENTA_H7_M7)
/* Enable GPIO clocks */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
Expand Down
4 changes: 4 additions & 0 deletions libraries/PDM/src/STM32H747_dfsdm/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_
{
xfer_status |= DMA_XFER_HALF;
// Invalidate Data Cache to get the updated content of the SRAM
#ifdef CORE_CM7
SCB_InvalidateDCache_by_Addr((uint32_t*)&RecBuff[0],sizeof(RecBuff)/2);
#endif
}
PDMIrqHandler(true);
}
Expand All @@ -86,7 +88,9 @@ void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filt
{
xfer_status |= DMA_XFER_FULL;
// Invalidate Data Cache to get the updated content of the SRAM
#ifdef CORE_CM7
SCB_InvalidateDCache_by_Addr((uint32_t*)&RecBuff[PDM_BUFFER_SIZE/2],sizeof(RecBuff)/2);
#endif
}
PDMIrqHandler(false);
}
Expand Down
5 changes: 5 additions & 0 deletions libraries/Portenta_SDRAM/src/SDRAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

#include "Arduino.h"

#if !defined(CORE_CM4)
#define SDRAM_END_ADDRESS (0x60800000)
#define SDRAM_START_ADDRESS (0x60000000)
#else
#define SDRAM_END_ADDRESS (0xC0800000)
#define SDRAM_START_ADDRESS (0xC0000000)
#endif

class SDRAMClass {
public:
Expand Down
12 changes: 10 additions & 2 deletions libraries/RPC/src/RPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ int RPCClass::begin(long unsigned int np, uint16_t nd) {
* The rpmsg service is initiate by the remote processor, on H7 new_service_cb
* callback is received on service creation. Wait for the callback
*/
OPENAMP_Wait_EndPointready(&rp_endpoints[ENDPOINT_RAW], millis() + 500);
OPENAMP_Wait_EndPointready(&rp_endpoints[ENDPOINT_RESPONSE], millis() + 500);
auto err = OPENAMP_Wait_EndPointready(&rp_endpoints[ENDPOINT_RAW], millis() + 500);
err |= OPENAMP_Wait_EndPointready(&rp_endpoints[ENDPOINT_RESPONSE], millis() + 500);

if (err == 0) {
initialized = true;
} else {
return 0;
}

// Send first dummy message to enable the channel
uint8_t message = 0x00;
Expand Down Expand Up @@ -226,6 +232,8 @@ int RPCClass::begin(long unsigned int np, uint16_t nd) {
return 0;
}

initialized = true;

return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/SocketWrapper/src/utility/wl_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ enum wl_enc_type { /* Values map to 802.11 encryption suites... */
ENC_TYPE_AUTO = 8
};

#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
#if defined(ARDUINO_PORTENTA_H7_M7)
#include "whd_version.h"
#define WIFI_FIRMWARE_LATEST_VERSION WHD_VERSION
#endif

#endif /* WL_DEFINITIONS_H_ */
#endif /* WL_DEFINITIONS_H_ */
13 changes: 12 additions & 1 deletion libraries/WiFi/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,22 @@ void arduino::WiFiClass::MACAddress(uint8_t *mac_address)

#define WIFI_FIRMWARE_PATH "/wlan/4343WA1.BIN"

#if defined(CORE_CM4)
#include "QSPIFBlockDevice.h"
mbed::BlockDevice *mbed::BlockDevice::get_default_instance()
{
static QSPIFBlockDevice default_bd(PD_11, PD_12, PE_2, PF_6, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
return &default_bd;
}
#endif

bool firmware_available = false;

#include "wiced_filesystem.h"
#include "resources.h"

void wiced_filesystem_mount_error(void) {
while (!Serial) {}
Serial.println("Failed to mount the filesystem containing the WiFi firmware.");
Serial.println("Usually that means that the WiFi firmware has not been installed yet"
" or was overwritten with another firmware.");
Expand All @@ -252,6 +262,7 @@ void wiced_filesystem_mount_error(void) {
}

void wiced_filesystem_firmware_error(void) {
while (!Serial) {}
Serial.println("Please run the \"WiFiFirmwareUpdater\" sketch once to install the WiFi firmware.");
whd_print_logbuffer();
while (1) {}
Expand All @@ -274,7 +285,7 @@ wiced_result_t whd_firmware_check_hook(const char* mounted_name, int mount_err)
return WICED_SUCCESS;
}
}
Serial.println("File not found");
if (Serial) { Serial.println("File not found\n"); }
closedir(dir);
}
wiced_filesystem_firmware_error();
Expand Down
4 changes: 2 additions & 2 deletions libraries/WiFi/src/utility/wl_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ enum wl_enc_type { /* Values map to 802.11 encryption suites... */
ENC_TYPE_AUTO = 8
};

#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
#if defined(ARDUINO_PORTENTA_H7_M7)
#include "whd_version.h"
#define WIFI_FIRMWARE_LATEST_VERSION WHD_VERSION
#endif

#endif /* WL_DEFINITIONS_H_ */
#endif /* WL_DEFINITIONS_H_ */
4 changes: 3 additions & 1 deletion libraries/openamp_arduino/src/openamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ int OPENAMP_check_for_message(void)

unsigned long millis();

void OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept, size_t deadline)
int OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept, size_t deadline)
{
while(!is_rpmsg_ept_ready(rp_ept) && (millis() < deadline)) {
MAILBOX_Poll(rvdev.vdev);
}
if (millis() >= deadline) {
printf("OPENAMP_Wait_EndPointready %X timed out\n\r", (unsigned int)rp_ept);
return -1;
}
return 0;
}

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
2 changes: 1 addition & 1 deletion libraries/openamp_arduino/src/openamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int OPENAMP_create_endpoint(struct rpmsg_endpoint *ept, const char *name,
int OPENAMP_check_for_message(void);

/* Wait loop on endpoint ready ( message dest address is know)*/
void OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept, size_t deadline);
int OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept, size_t deadline);

#ifdef __cplusplus
}
Expand Down
Loading