Made HOWTO a tiny bit better.

master
Marcel 1 month ago
parent e0e23a1a19
commit 0c425e8a04
  1. 97
      Documentation/HOWTO-change-firmware-and-compile-it_MeesElectronics.md

@ -52,83 +52,17 @@ To test if you can compile the firmware try it:
Be patient, this can take up to 15 minutes to complete. Wait for the command prompt to return. You should not see any errors.
## Define new board, the theory
## Define a new board
In order to build custom firmware for a new board it has to be defined in several files.
### Makefile
BOARD_MODEL defines the target board. It is a unique 8 bit number.
BOARD_VARIANT defines the variant of the board. A board could come with different LoRa transceivers, for example. It is also a unique 8 bit number.
Every target board has a section 'firmware-<board_name>', 'upload-<board-name>' and 'release-<board-name>'
### boards.h
Both BOARD_MODEL and BOARD_VARIANT are #defines in this file. They are used to define the pinout of the SPI port and if it has certain peripherals such as a screen BLE etc.
Let's see an example:
#elif BOARD_MODEL == BOARD_HELTEC32_V3
#define IS_ESP32S3 true
#define HAS_DISPLAY true
#define DISPLAY OLED
#define HAS_BLUETOOTH false
#define HAS_BLE true
#define HAS_PMU true
#define HAS_CONSOLE true
#define HAS_EEPROM true
#define HAS_INPUT true
#define HAS_SLEEP true
#define PIN_WAKEUP GPIO_NUM_0
#define WAKEUP_LEVEL 0
#define INTERFACE_COUNT 1
#define OCP_TUNED 0x38
const int pin_btn_usr1 = 0;
#if defined(EXTERNAL_LEDS)
const int pin_led_rx = 13;
const int pin_led_tx = 14;
#else
const int pin_led_rx = 35;
const int pin_led_tx = 35;
#endif
const uint8_t interfaces[INTERFACE_COUNT] = {SX1262};
const bool interface_cfg[INTERFACE_COUNT][3] = {
// SX1262
{
true, // DEFAULT_SPI
true, // HAS_TCXO
true // DIO2_AS_RF_SWITCH
},
};
const int8_t interface_pins[INTERFACE_COUNT][10] = {
// SX1262
{
8, // pin_ss
9, // pin_sclk
10, // pin_mosi
11, // pin_miso
13, // pin_busy
14, // pin_dio
12, // pin_reset
-1, // pin_txen
-1, // pin_rxen
-1 // pin_tcxo_enable
}
};
If we want to add support for a new board we have to add a new section for this board. Here we define all the features it has or not has.
Go to the directory `~/RNode_Firmware_CE`. This is the source code of the RNode firmware. Here you will find all the files needed to compile the firmware. You can edit these files with any text editor you like.
## Define new board for real
Let's say we want to add support for the Waveshare ESP32-S3 Pico with an SX1278 LoRa transceiver. First we have to define a BOARD_MODEL. This is an 8 bit value that is used in the source code to select the right code for the hardware. Let's choose 0x61 as the BOARD_MODEL as this number is not used yet. Optional we can also define a BOARD_VARIANT. This defines the variant of the board. A board could come with different LoRa transceivers, for example. It is also a unique 8 bit number. For now, we ignore this BOARD_VARIANT and only use the BOARD_MODEL.
Go to the directory `~/RNode_Firmware_CE`. This is the source code of the RNode firmware. Here you will find all the files needed to compile the firmware. You can edit these files with any text editor you like.
### Makefile
Let's say we want to add support for the Waveshare ESP32-S3 Pico with an SX1278 LoRa transceiver. First we have to define a BOARD_MODEL. This is an 8 bit value that is used in the source code to select the right code for the hardware. Let's choose 0x61 as the BOARD_MODEL as this number is not used yet.
The source code is compiled using `make` and the file called *Makefile*.
The source code is compiled using `make` and the file called *Makefile*. In this file, the following three entries for our new board have to be added. The exact place is not critical. But it is good practice to put them alongside the already present sections for firmware, upload and release.
Every target board has a section `firmware-<board_name>`, `upload-<board-name>` and `release-<board-name>`. In the Makefile, three new sections for our new board have to be added. The exact place is not critical. But it is good practice to put them alongside the already present sections for firmware, upload and release.
```
# Added board from Mees Electronics
@ -153,13 +87,22 @@ release-waveshare-esp32-s3-pico:
cp build/esp32.esp32.waveshare-esp32-s3-pico/RNode_Firmware_CE.ino.bin build/rnode_firmware_waveshare-esp32-s3-pico.bin
cp build/esp32.esp32.waveshare-esp32-s3-pico/RNode_Firmware_CE.ino.bootloader.bin build/rnode_firmware_waveshare-esp32-s3-pico.bootloader
cp build/esp32.esp32.waveshare-esp32-s3-pico/RNode_Firmware_CE.ino.partitions.bin build/rnode_firmware_waveshare-esp32-s3-pico.partitions
zip --junk-paths ./Release/rnode_firmware_waveshare-esp32-s3-pico.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_t3s3_sx126xrnode_firmware_waveshare-esp32-s3-pico.boot_app0 build/rnode_firmware_waveshare-esp32-s3-pico.bin build/rnode_firmware_waveshare-esp32-s3-pico.bootloader build/rnode_firmware_waveshare-esp32-s3-pico.partitions
zip --junk-paths ./Release/rnode_firmware_waveshare-esp32-s3-pico.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_waveshare-esp32-s3-pico.boot_app0 build/rnode_firmware_waveshare-esp32-s3-pico.bin build/rnode_firmware_waveshare-esp32-s3-pico.bootloader build/rnode_firmware_waveshare-esp32-s3-pico.partitions
rm -r build
```
The file `Board.h` is the most important file to edit. This is the place where the supported boards are defined. For our new board should, a new section has to be added.
### Boards.h
The file `Board.h` is the most important file to edit. This is the place where the supported boards are defined. For our new board should, a new section has to be added. This section defines the pinout of the SPI port and if it has certain peripherals such as a screen or BLE.
First, the new board has to be defined at the beginning of the file. Search for the line `#define MODEL_FF 0xFF // Homebrew board, max 14dBm output power` and add our definition below that line. Like so:
Search for the line `#if MCU_VARIANT == MCU_ESP32`. This is the part where all the ESP32 variant are defined. This section stops at the line `#elif MCU_VARIANT == MCU_NRF52`. From here the definitions for the NRF52 board begin.
#define MODEL_FF 0xFF // Homebrew board, max 14dBm output power
// Board added by Mees Electronics
#define BOARD_WAVESHARE_ESP32_S3_PICO 0x61 // Waveshare ESP32 S3 Pico
Next, search for the line `#if MCU_VARIANT == MCU_ESP32`. This is the part where all the ESP32 variant are defined. This section stops at the line `#elif MCU_VARIANT == MCU_NRF52`. From here the definitions for the NRF52 board begin.
Somewhere between these to lines we have to add our board definition. It is good practice to add it at the end, just before the following code:
@ -221,6 +164,8 @@ Like so:
#error An unsupported ESP32 board was selected. Cannot compile RNode firmware.
#endif
### Utilities.h
Also, in the file **Utilities.h** add entry. Again, inside the '#if MCU_VARIANT == MCU_ESP32'.
#elif BOARD_MODEL == BOARD_WAVESHARE_ESP32_S3_PICO
@ -250,6 +195,8 @@ The file **display.h** also has a board definition section. If the new board has
disp_mode = DISP_MODE_LANDSCAPE;
display.setRotation(0);
### Power.h
The file **Power.h** must also have a board definition. And also proper definitions in **void measure_battery()** and **bool init_pmu()**. These are more elaborate and not yet fully understood, but probably used when the board has a battery installed. If the new board does not have a battery, do not define anything here!
#elif BOARD_MODEL == BOARD_WAVESHARE_ESP32_S3_PICO

Loading…
Cancel
Save