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

Fix memory size defines #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 6 additions & 7 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ typedef bool boolean;
typedef uint8_t byte;
typedef uint16_t word;

// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
//
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "avr/io.h"

#include "binary.h"
#include "itoa.h"

Expand Down Expand Up @@ -89,6 +82,12 @@ void loop( void ) ;
// Include board variant
#include "variant.h"

// some libraries and sketches depend on this AVR stuff,
// assuming Arduino.h or WProgram.h automatically includes it...
#include "avr/pgmspace.h"
#include "avr/interrupt.h"
#include "avr/io.h"

#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
Expand Down
23 changes: 20 additions & 3 deletions cores/arduino/avr/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,27 @@
#ifndef _IO_H_
#define _IO_H_

#define RAMSTART 0x20000000
#define RAMSIZE (20 * 1024)
#include <Arduino.h>
#include <assert.h>

#define RAMSTART (SRAM_BASE)
#define RAMSIZE (SRAM_SIZE_MAX)
#define RAMEND (RAMSTART + RAMSIZE - 1)

#define E2END 0xfff
#if defined(DATA_EEPROM_BASE) && defined(DATA_EEPROM_END)
#define REAL_E2END (DATA_EEPROM_END - DATA_EEPROM_BASE)
#elif defined(DATA_EEPROM_BASE) && defined(DATA_EEPROM_BANK2_BASE) && defined(DATA_EEPROM_BANK1_END) && defined(DATA_EEPROM_BANK2_END)
#define REAL_E2END (DATA_EEPROM_BANK1_END - DATA_EEPROM_BASE + 1 + DATA_EEPROM_BANK2_END - DATA_EEPROM_BANK2_BASE)
#else
#error "Cannot determine EEPROM size"
#endif

#if defined(STM32L0_CONFIG_EEPROM_RESERVED)
static_assert(STM32L0_CONFIG_EEPROM_RESERVED <= REAL_E2END + 1, "STM32L0_CONFIG_EEPROM_RESERVED bigger than EEPROM");
#define E2END (REAL_E2END - STM32L0_CONFIG_EEPROM_RESERVED)
#else
#define E2END REAL_E2END
#endif


#endif
3 changes: 3 additions & 0 deletions variants/B-L072Z-LRWAN1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#define STM32L0_CONFIG_HSECLK 0
#define STM32L0_CONFIG_SYSOPT 0

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

/** Master clock frequency */
#define VARIANT_MCK F_CPU

Expand Down
3 changes: 3 additions & 0 deletions variants/Cicada-L082CZ/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@

#define STM32L0_CONFIG_SFLASH_DATA_START (256 * 1024)

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

#define USBCON

/** Master clock frequency */
Expand Down
3 changes: 3 additions & 0 deletions variants/Cricket-L082CZ/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@

#define STM32L0_CONFIG_SFLASH_DATA_START (256 * 1024)

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

#define USBCON

/** Master clock frequency */
Expand Down
3 changes: 3 additions & 0 deletions variants/Gnat-L082CZ/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
#define STM32L0_CONFIG_PIN_GNSS_RX STM32L0_GPIO_PIN_PA10_USART1_RX
#define STM32L0_CONFIG_PIN_GNSS_TX STM32L0_GPIO_PIN_PA9_USART1_TX

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

#define USBCON

/** Master clock frequency */
Expand Down
3 changes: 3 additions & 0 deletions variants/Grasshopper-L082CZ/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

#define STM32L0_CONFIG_SFLASH_DATA_START (256 * 1024)

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

#define USBCON

/** Master clock frequency */
Expand Down
3 changes: 3 additions & 0 deletions variants/I-NUCLEO-LRWAN1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#define STM32L0_CONFIG_HSECLK 0
#define STM32L0_CONFIG_SYSOPT 0

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

/** Master clock frequency */
#define VARIANT_MCK F_CPU

Expand Down
3 changes: 3 additions & 0 deletions variants/NUCLEO-L073RZ/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#define STM32L0_CONFIG_HSECLK 0
#define STM32L0_CONFIG_SYSOPT 0

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

/** Master clock frequency */
#define VARIANT_MCK F_CPU

Expand Down
3 changes: 3 additions & 0 deletions variants/P-NUCLEO-LRWAN1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#define STM32L0_CONFIG_HSECLK 0
#define STM32L0_CONFIG_SYSOPT 0

// Reserve some room at the end of EEPROM for LoRaWAN library
#define STM32L0_CONFIG_EEPROM_RESERVED 2048

/** Master clock frequency */
#define VARIANT_MCK F_CPU

Expand Down