Skip to content
Draft
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
59 changes: 58 additions & 1 deletion Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
#define BOARD_RAK4631 0x51
#define MODEL_11 0x11 // RAK4631, 433 Mhz
#define MODEL_12 0x12 // RAK4631, 868 Mhz
#define BOARD_RAK3401 0x52 // RAK3401 + RAK13302 (nRF52840 + SX1262 + SKY66122 1W FEM)
#define MODEL_13 0x13 // RAK3401 + RAK13302, 433 MHz
#define MODEL_14 0x14 // RAK3401 + RAK13302, 868 MHz

#define PIN_3V3_EN 34 // WB_IO2 — 5V boost + 3V3_S rail (RAK13302 FEM)

#define PRODUCT_HMBRW 0xF0
#define BOARD_HMBRW 0x32
Expand Down Expand Up @@ -140,7 +145,7 @@
#endif

#ifndef MODEM
#if BOARD_MODEL == BOARD_RAK4631
#if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_RAK3401
#define MODEM SX1262
#elif BOARD_MODEL == BOARD_GENERIC_NRF52
#define MODEM SX1262
Expand Down Expand Up @@ -752,6 +757,58 @@
const int pin_led_tx = LED_GREEN;
const int pin_tcxo_enable = -1;

#elif BOARD_MODEL == BOARD_RAK3401
#define HAS_EEPROM false
#define HAS_DISPLAY false // RAK19007 base board has no display in this kit
#define HAS_BLUETOOTH false
#define HAS_BLE true
#define HAS_CONSOLE false
#define HAS_PMU false
#define HAS_NP false
#define HAS_SD false
#define HAS_TCXO true
#define HAS_RF_SWITCH_RX_TX true
#define HAS_BUSY true
#define HAS_INPUT true
#define DIO2_AS_RF_SWITCH true // SKY66122 CTX driven by DIO2 (hardware TX/RX switch)
#define CONFIG_UART_BUFFER_SIZE 6144
#define CONFIG_QUEUE_SIZE 6144
#define CONFIG_QUEUE_MAX_LENGTH 200
#define EEPROM_SIZE 296
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED
#define BLE_MANUFACTURER "RAK Wireless"
#define BLE_MODEL "RAK3401"

// RAK13302 SKY66122-11 FEM: +8 dBm PA gain (constant per datasheet),
// 30 dBm (1 W) max output. Gain values from Meshtastic config.
// LORA_LNA_GAIN corrects RSSI for the +11-13 dB LNA (midpoint 12).
#define HAS_LORA_PA true
#define PA_MAX_OUTPUT 30
#define PA_GAIN_POINTS 22
#define PA_GAIN_VALUES 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8

#define HAS_LORA_LNA true
#define LORA_LNA_GAIN 12
#define LORA_LNA_GVT 8

// RAK13302 SX1262 pins — all on P0 bus.
const int pin_rxen = 21; // IO3 = SKY66122 CSD+CPS FEM power enable (stays HIGH)
// See also SX126X_POWER_EN in variant.h — same pin.
const int pin_txen = -1; // CTX via DIO2_AS_RF_SWITCH (SX1262 hardware control)
const int pin_reset = 4;
const int pin_cs = 26;
const int pin_sclk = 3;
const int pin_mosi = 30;
const int pin_miso = 29;
const int pin_busy = 9;
const int pin_dio = 10;
const int pin_led_rx = LED_BLUE;
const int pin_led_tx = LED_GREEN;
const int pin_tcxo_enable = -1; // TCXO powered by DIO3 via enableTCXO(), not a GPIO

// User Input Button
const int pin_btn_usr1 = 31; // AIN1 (WB_A1) on J11 header / connector pin 22

#elif BOARD_MODEL == BOARD_TECHO
#define _PINNUM(port, pin) ((port) * 32 + (pin))
#define MODEM SX1262
Expand Down
8 changes: 4 additions & 4 deletions RNode_Firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ void setup() {
boot_seq();
#endif

#if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_HELTEC_T114 && BOARD_MODEL != BOARD_TECHO && BOARD_MODEL != BOARD_T3S3 && BOARD_MODEL != BOARD_TBEAM_S_V1 && BOARD_MODEL != BOARD_HELTEC32_V4
#if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_RAK3401 && BOARD_MODEL != BOARD_HELTEC_T114 && BOARD_MODEL != BOARD_TECHO && BOARD_MODEL != BOARD_T3S3 && BOARD_MODEL != BOARD_TBEAM_S_V1 && BOARD_MODEL != BOARD_HELTEC32_V4
// Some boards need to wait until the hardware UART is set up before booting
// the full firmware. In the case of the RAK4631 and Heltec T114, the line below will wait
// until a serial connection is actually established with a master. Thus, it
// is disabled on this platform.
// the full firmware. In the case of the RAK4631, RAK3401, and Heltec T114,
// the line below will wait until a serial connection is actually established
// with a master. Thus, it is disabled on this platform.
while (!Serial);
#endif

Expand Down
11 changes: 11 additions & 0 deletions Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ extern RNS::Reticulum reticulum;
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
void led_id_on() { }
void led_id_off() { }
#elif BOARD_MODEL == BOARD_RAK3401
void led_rx_on() { digitalWrite(pin_led_rx, HIGH); }
void led_rx_off() { digitalWrite(pin_led_rx, LOW); }
void led_tx_on() { digitalWrite(pin_led_tx, HIGH); }
void led_tx_off() { digitalWrite(pin_led_tx, LOW); }
void led_id_on() { }
void led_id_off() { }
#elif BOARD_MODEL == BOARD_HELTEC_T114
// Heltec T114 pulls pins LOW to turn on
void led_rx_on() { digitalWrite(pin_led_rx, LOW); }
Expand Down Expand Up @@ -1343,6 +1350,8 @@ void setTXPower() {

if (model == MODEL_11) LoRa->setTxPower(mapped_lora_txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_12) LoRa->setTxPower(mapped_lora_txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_13) LoRa->setTxPower(mapped_lora_txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_14) LoRa->setTxPower(mapped_lora_txp, PA_OUTPUT_RFO_PIN);

if (model == MODEL_C6) LoRa->setTxPower(mapped_lora_txp, PA_OUTPUT_RFO_PIN);
if (model == MODEL_C7) LoRa->setTxPower(mapped_lora_txp, PA_OUTPUT_RFO_PIN);
Expand Down Expand Up @@ -1693,6 +1702,8 @@ bool eeprom_model_valid() {
if (model == MODEL_C6 || model == MODEL_C7) {
#elif BOARD_MODEL == BOARD_RAK4631
if (model == MODEL_11 || model == MODEL_12) {
#elif BOARD_MODEL == BOARD_RAK3401
if (model == MODEL_13 || model == MODEL_14) {
#elif BOARD_MODEL == BOARD_HUZZAH32
if (model == MODEL_FF) {
#elif BOARD_MODEL == BOARD_GENERIC_ESP32
Expand Down
73 changes: 73 additions & 0 deletions boards/rak3401.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"build": {
"arduino": {
"ldscript": "nrf52840_s140_v6.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
[
"0x239A",
"0x8029"
],
[
"0x239A",
"0x0029"
],
[
"0x239A",
"0x002A"
],
[
"0x239A",
"0x802A"
]
],
"usb_product": "WisCore RAK3401 Board",
"mcu": "nrf52840",
"variant": "rak3401",
"variants_dir": "variants",
"bsp": {
"name": "adafruit"
},
"softdevice": {
"sd_flags": "-DS140",
"sd_name": "s140",
"sd_version": "6.1.1",
"sd_fwid": "0x00B6"
},
"bootloader": {
"settings_addr": "0xFF000"
}
},
"connectivity": [
"bluetooth"
],
"debug": {
"jlink_device": "nRF52840_xxAA",
"svd_path": "nrf52840.svd"
},
"frameworks": [
"arduino"
],
"name": "WisCore RAK3401 Board",
"upload": {
"maximum_ram_size": 248832,
"maximum_size": 815104,
"speed": 115200,
"protocol": "nrfutil",
"protocols": [
"jlink",
"nrfjprog",
"nrfutil",
"stlink"
],
"use_1200bps_touch": true,
"require_upload_port": true,
"wait_for_upload_port": true
},
"url": "https://www.rakwireless.com",
"vendor": "RAKwireless"
}
2 changes: 2 additions & 0 deletions extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def device_provision(env):
env.Execute("rnodeconf --product c3 --model c8 --hwrev 1 --rom " + env.subst("$UPLOAD_PORT"))
case "rak4631" | "rak4631_local":
env.Execute("rnodeconf --product 10 --model 12 --hwrev 1 --rom " + env.subst("$UPLOAD_PORT"))
case "rak3401":
env.Execute("rnodeconf --product 10 --model 14 --hwrev 1 --rom " + env.subst("$UPLOAD_PORT"))
case "heltec_t114" | "heltec_t114_local":
env.Execute("rnodeconf --product c2 --model c7 --hwrev 1 --rom " + env.subst("$UPLOAD_PORT"))
case _:
Expand Down
33 changes: 33 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,39 @@ lib_deps =
https://github.com/attermann/microStore.git
https://github.com/attermann/microReticulum.git

[env:wiscore_rak3401]
platform = nordicnrf52
board = rak4630
custom_variant = rak4631
board_build.partitions = no_ota.csv
board_build.filesystem = littlefs
build_src_filter = ${env.build_src_filter} +<variants/rak3401>
build_unflags =
${env.build_unflags}
-fno-exceptions ; Required for exception handling on nordicnrf52
-fno-rtti ; Required for exception handling on nordicnrf52
--specs=nano.specs ; Required for exception handling on nordicnrf52
build_flags =
${env.build_flags}
-fexceptions ; Required for exception handling on nordicnrf52
-frtti ; Required for exception handling on nordicnrf52
--specs=nosys.specs ; Required for exception handling on nordicnrf52
-I variants/rak3401
-DBOARD_MODEL=BOARD_RAK3401
-DURTN_PATH_TABLE_MAX_RECS=25
-DRNS_DEFAULT_ALLOCATOR=RNS_HEAP_ALLOCATOR
-DRNS_CONTAINER_ALLOCATOR=RNS_HEAP_ALLOCATOR
-DRNS_USE_FS
-DHAS_RNS
-DUSTORE_USE_INTERNALFS
;-DUSTORE_USE_UNIVERSALFS
;-DRNS_PERSIST_PATHS
;-DRNS_MEM_LOG
;-DRNS_HEAP_POOL_BUFFER_SIZE=65536
lib_deps =
${env.lib_deps}
https://github.com/attermann/microStore.git
https://github.com/attermann/microReticulum.git


[env:ttgo-t-beam-local]
Expand Down
9 changes: 9 additions & 0 deletions sx126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ bool sx126x::preInit() {
#elif BOARD_MODEL == BOARD_TECHO
SPI.setPins(pin_miso, pin_sclk, pin_mosi);
SPI.begin();
#elif BOARD_MODEL == BOARD_RAK3401
// spiModem is already constructed with P0 pins (29/3/30) via Config.h using
// the pin_miso/pin_sclk/pin_mosi values from Boards.h. The setPins() call is
// defensive and documents intent; SPI.begin() would work without it.
SPI.setPins(pin_miso, pin_sclk, pin_mosi); // P0: MISO=29, SCK=3, MOSI=30
SPI.begin();
#else
SPI.begin();
#endif
Expand Down Expand Up @@ -637,6 +643,9 @@ void sx126x::enableTCXO() {
#if HAS_TCXO
#if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_XIAO_S3
uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF};
#elif BOARD_MODEL == BOARD_RAK3401
// RAK13302 specifies DIO3 TCXO at 1.8V (SX126X_DIO3_TCXO_VOLTAGE 1.8)
uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF};
#elif BOARD_MODEL == BOARD_TBEAM
uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF};
#elif BOARD_MODEL == BOARD_TDECK
Expand Down
18 changes: 18 additions & 0 deletions variants/rak3401/WVariant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <stdint.h>
#include <stdbool.h>
#include <nrf.h>
#include <nrf_soc.h>
#include <nrf_sdm.h>
#include <nrf_gpio.h>

#ifdef __cplusplus
extern "C" {
#endif

extern const uint32_t g_ADigitalPinMap[] ;

#ifdef __cplusplus
} // extern "C"
#endif
48 changes: 48 additions & 0 deletions variants/rak3401/variant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "variant.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include "nrf.h"

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

const uint32_t g_ADigitalPinMap[] =
{
// P0
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
8 , 9 , 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,

// P1
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47
};


void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);

pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);

// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);

// Enable SKY66122 FEM on the RAK13302 module.
// CSD and CPS are tied together, routed to IO3 (P0.21).
// Must be HIGH before radio init.
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
delay(1);
}

#ifdef __cplusplus
}
#endif
Loading