logo elektroda
logo elektroda
X
logo elektroda

Configuring OpenBeken on ESP32 with 4MB Default Using sdkconfig.defaults.esp32

insmod 9462 228
ADVERTISEMENT
  • #151 21595819
    p.kaczmarek2
    Moderator Smart Home
    UPDATE: I moved ESP8266 discussion to separate topic. OBK can now run on ESP8266.
    Running OpenBeken/OBK on ESP8266 devices
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #152 21604297
    divadiow
    Level 35  
    ESP OTA list is frozen at 1.18.121

    1.18.122 was the big w800 + berry merge
    Configuring OpenBeken on ESP32 with 4MB Default Using sdkconfig.defaults.esp32

    Also the ESP downloads in the table above the assets are dead
    Configuring OpenBeken on ESP32 with 4MB Default Using sdkconfig.defaults.esp32
  • #153 21604388
    p.kaczmarek2
    Moderator Smart Home
    Which commits and changes were introduces there?
    Helpful post? Buy me a coffee.
  • Helpful post
    #154 21604511
    insmod
    Level 27  
    >>21604388
    I separated builds to 2M and 4M variants
  • #157 21611142
    divadiow
    Level 35  
    :)
    Configuring OpenBeken on ESP32 with 4MB Default Using sdkconfig.defaults.esp32

    Added after 1 [minutes]:

    bum. didn't add C5 and C61
  • ADVERTISEMENT
  • #159 21611147
    divadiow
    Level 35  
    just a little GPT thing 'I' made
    Code: Python
    Log in, to see the code


    Added after 5 [minutes]:

    actually, it's not fetching all assets. hmm

    Added after 5 [minutes]:

    Code: Python
    Log in, to see the code
  • #161 21629835
    p.kaczmarek2
    Moderator Smart Home
    That's a great development. Let me know which your PRs are safe to merge.

    Well, T0H and T0L , or, more broadly speaking, WS2812 timings are derived from two things - from fake data output values and from SPI clock.
    Here is topic showing that: https://www.elektroda.com/rtvforum/topic4111570.html
    So, we would probably need a lookup table for different times if needed?
    Helpful post? Buy me a coffee.
  • #162 21629878
    insmod
    Level 27  
    I'm away for now (for ~4 hours), will ping once i've retested esp.
    LN update can be merged.
    If OTA is working in ECR update pull (both rest and http), then it can be merged too.
  • #163 21629951
    divadiow
    Level 35  
    I can test things this afternoon if needed 🤓
  • ADVERTISEMENT
  • #165 21630048
    divadiow
    Level 35  
    Should this be a PR?https://github.com/openshwprojects/OpenTR6260/compare/master...NonPIayerCharacter%3AOpenTR6260%3Amaster
  • #166 21630051
    insmod
    Level 27  
    >>21630048
    .gitmodules points at my repo, but even if it wasn't, sdk/OpenTR6260 still points to last commit.
  • #167 21630053
    divadiow
    Level 35  
    Ah ok ok 😃

    Added after 1 [hours] 18 [minutes]:

    1743_merge_d3a54bd71550

    GUI and web app methods work as normal to and from this PR. HTTP server method does not work. It doesn't work on 1.18.145 either. Just this in log:

    Code: Text
    Log in, to see the code


    Screenshot showing: “Wifi RSSI: Good (-50dBm)” on a dark background
  • #168 21630161
    insmod
    Level 27  
    Now also on LN882H.
    I used SPI, not native WS2811. That way compatibility with OBK code was kept.
    I'm actually surprised that it worked. There is no way to set spi frequency precisely. Only through a divider.
    So while BK and ESP spi frequency is 3MHz, LN882H is 2.125Mhz (i think). Formula is (br + 1) * 5 * (1 / pclk), where br = 16 and pclk is 40M? br is 2^x, x >= 1 && x <= 8

    LN882H was tested on 12 WS2812B.
    Re-tested ESP again, can be merged.

    Added after 3 [hours] 12 [minutes]:

    ESP32-C2 works
  • ADVERTISEMENT
  • #169 21630291
    divadiow
    Level 35  
    Cool cool.

    insmod wrote:
    used SPI, not native WS2811


    Curious about this. What's the difference and why not native WS2811?
  • #170 21630299
    insmod
    Level 27  
    >>21630291
    I tried it, but it wasn't working properly.
    Main reason, i believe - it expects raw pixel data. We supply it pre-translated for SPI.

    Added after 37 [minutes]:

    RIP indentations in obk_config.h
    @p.kaczmarek2 should i restore them in pull request?
  • #171 21630358
    p.kaczmarek2
    Moderator Smart Home
    Oh? Did something broke? If so, please do. I merged some pending PRs and now I am about to try something with BK7238 IR
    Helpful post? Buy me a coffee.
  • #172 21630398
    insmod
    Level 27  
    Restored indentations, plus fixed ESP build
  • #173 21630621
    insmod
    Level 27  
    Well, i managed to get native WS2811 working on LN882H by disabling translation, but it stops working sometimes. Chip also gets rather hot.
    Probably done something wrong. Not a priority for me either.

    Need spiled for any other chip?

    commit 5a702ce796142bbde38aa30b4ffdc761811345ea
    Author: NonPIayerCharacter <18557343+NonPIayerCharacter@users.noreply.github.com>
    Date:   Sun Aug 10 09:55:43 2025 +0300
    
        index on bk7231t_alt_spiled: 0f9b07d6 Merge remote-tracking branch 'refs/remotes/origin/main' into bk7231t_alt_spiled
    
    diff --git a/src/driver/drv_sm16703P.c b/src/driver/drv_sm16703P.c
    index f000a40b33ca5b4a9240ef4248eb88a4004f173e..cd720cc37ceae3dea6ef5fe8a78165cf8f2165c4 100644
    --- a/src/driver/drv_sm16703P.c
    +++ b/src/driver/drv_sm16703P.c
    @@ -13,23 +13,13 @@
     #include "drv_local.h"
     #include "drv_spiLED.h"
     
    +#if PLATFORM_LN882H
    +#define SEND_RAW_DATA 1
    +#endif
    +
     // Number of pixels that can be addressed
     uint32_t pixel_count;
     
    -void SM16703P_GetPixel(uint32_t pixel, byte *dst) {
    -   int i;
    -   uint8_t *input;
    -
    -   if (spiLED.msg == 0)
    -      return;
    -   
    -   input = spiLED.buf + spiLED.ofs + (pixel * 3 * 4);
    -
    -   for (i = 0; i < 3; i++) {
    -      *dst++ = reverse_translate_byte(input + i * 4);
    -   }
    -}
    -
     enum ColorChannel {
        COLOR_CHANNEL_RED,
        COLOR_CHANNEL_GREEN,
    @@ -45,6 +35,30 @@ const enum ColorChannel default_color_channel_order[3] = {
     enum ColorChannel *color_channel_order = default_color_channel_order;
     int pixel_size = 3; // default is RGB -> 3 bytes per pixel
     
    +void SM16703P_GetPixel(uint32_t pixel, byte* dst)
    +{
    +   int i;
    +   uint8_t* input;
    +
    +   if(spiLED.msg == 0)
    +      return;
    +
    +#if SEND_RAW_DATA
    +   input = spiLED.buf + spiLED.ofs + (pixel * pixel_size);
    +#else
    +   input = spiLED.buf + spiLED.ofs + (pixel * 3 * 4);
    +#endif
    +
    +   for(i = 0; i < 3; i++)
    +   {
    +#if SEND_RAW_DATA
    +      * dst++ = input + i * pixel_count;
    +#else
    +      * dst++ = reverse_translate_byte(input + i * 4);
    +#endif
    +   }
    +}
    +
     bool SM16703P_VerifyPixel(uint32_t pixel, byte r, byte g, byte b) {
        byte real[3];
        SM16703P_GetPixel(pixel, real);
    @@ -86,7 +100,11 @@ void SM16703P_setPixel(int pixel, int r, int g, int b, int c, int w) {
                 ADDLOG_ERROR(LOG_FEATURE_CMD, "Unknown color channel %d at index %d", color_channel_order[i], i);
                 return;
           }
    +#if SEND_RAW_DATA
    +      spiLED.buf[spiLED.ofs + i + (pixel * pixel_size)] = pcolor;
    +#else
           translate_byte(pcolor, spiLED.buf + (spiLED.ofs + i * 4 + (pixel * pixel_size * 4)));
    +#endif
        }
     }
     void SM16703P_setMultiplePixel(uint32_t pixel, uint8_t *data, bool push) {
    @@ -135,10 +153,15 @@ void SM16703P_scaleAllPixels(int scale) {
     
        for (pixel = 0; pixel < pixel_count; pixel++) {
           for (ofs = 0; ofs < 3; ofs++) {
    +#if SEND_RAW_DATA
    +         data = spiLED.buf + (spiLED.ofs + ofs * 4 + (pixel * pixel_size));
    +         b = SCALE8_PIXEL(*data, scale);
    +#else
              data = spiLED.buf + (spiLED.ofs + ofs * 4 + (pixel * 3 * 4));
              b = reverse_translate_byte(data);
              b = SCALE8_PIXEL(b, scale);
              translate_byte(b, data);
    +#endif
           }
        }
     }
    diff --git a/src/driver/drv_spiLED.c b/src/driver/drv_spiLED.c
    index e88ea580d65f1e20fdc82dd92a312de3ee23bcbb..47e7cbcfee1ae2bb73a5292e153b4d1f1476ba4d 100644
    --- a/src/driver/drv_spiLED.c
    +++ b/src/driver/drv_spiLED.c
    @@ -29,6 +29,11 @@ void SPIDMA_Deinit(void) {
     }
     
     #endif
    +
    +#if PLATFORM_LN882H
    +#define SEND_RAW_DATA 1
    +#endif
    +
     static uint8_t data_translate[4] = { 0b10001000, 0b10001110, 0b11101000, 0b11101110 };
     
     
    @@ -88,7 +93,12 @@ void SPILED_InitDMA(int numBytes) {
        spiLED.padding = 64;
     
        // Prepare buffer
    +#if SEND_RAW_DATA
    +   uint32_t buffer_size = spiLED.ofs + (numBytes * 3);
    +   spiLED.padding = 0;
    +#else
        uint32_t buffer_size = spiLED.ofs + (numBytes * 4) + spiLED.padding; //Add `spiLED.ofs` bytes for "Reset"
    +#endif
     #if PLATFORM_ESPIDF
        spiLED.buf = heap_caps_malloc(sizeof(byte) * (buffer_size), MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
     #else
    diff --git a/src/driver/drv_spidma.c b/src/driver/drv_spidma.c
    index 934809917d7bb56b203dad0ac0b5fe127542815d..8583435d9bd42afe82ad2d9a3f9b9b694f98e69e 100644
    --- a/src/driver/drv_spidma.c
    +++ b/src/driver/drv_spidma.c
    @@ -607,7 +607,7 @@ void SPIDMA_Deinit(void)
     #include "drv_spidma.h"
     #include "../hal/ln882h/hal_pinmap_ln882h.h"
     #include "hal/hal_dma.h"
    -#include "hal/hal_spi.h"
    +#include "hal/hal_ws2811.h"
     
     extern int spidma_led_pin;
     static int current_pin = 6;
    @@ -617,50 +617,37 @@ void SPIDMA_Init(struct spi_message* msg)
        current_pin = spidma_led_pin > 0 ? spidma_led_pin : 6;
        lnPinMapping_t* pin = g_pins + current_pin;
     
    -   hal_gpio_pin_afio_select(pin->base, pin->pin, SPI0_MOSI);
    -   hal_gpio_pin_afio_en(pin->base, pin->pin, HAL_ENABLE);
    -   
    -   spi_init_type_def spi_init =
    -   {
    -      .spi_baud_rate_prescaler = SPI_BAUDRATEPRESCALER_16,
    -      .spi_mode = SPI_MODE_MASTER,
    -      .spi_data_size = SPI_DATASIZE_8B,
    -      .spi_first_bit = SPI_FIRST_BIT_MSB,
    -      .spi_cpol = SPI_CPOL_LOW,
    -      .spi_cpha = SPI_CPHA_1EDGE,
    -   };
    -   
    -   hal_spi_init(SPI0_BASE, &spi_init);
    -   hal_spi_en(SPI0_BASE, HAL_ENABLE);
    -   hal_spi_ssoe_en(SPI0_BASE, HAL_DISABLE);
    -   
    +   hal_gpio_pin_afio_select(pin->base, pin->pin, WS2811_OUT);
    +   sysc_cmp_ws2811_gate_en_setf(1);
    +   ws2811_br_setf(WS2811_BASE, 16);
    +   ws2811_ws_en_setf(WS2811_BASE, 1);
    +   ws2811_dma_en_setf(WS2811_BASE, 1);
    +   ws2811_int_en_setf(WS2811_BASE, 0);
    +
        dma_init_t_def dma_init =
        {
    -      .dma_mem_addr = (uint32_t)msg->send_buf,
    +      .dma_mem_addr = msg->send_buf,
           .dma_data_num = msg->send_len,
           .dma_dir = DMA_READ_FORM_MEM,
           .dma_mem_inc_en = DMA_MEM_INC_EN,
    -      .dma_p_addr = SPI0_DATA_REG,
    -      .dma_p_size = DMA_P_SIZE_8_BIT,
    -      .dma_mem_size = DMA_MEM_SIZE_8_BIT,
    +      .dma_p_addr = WS2811_DATA_REG,//SPI0_DATA_REG,
    +      //.dma_p_size = DMA_P_SIZE_8_BIT,
    +      //.dma_mem_size = DMA_MEM_SIZE_8_BIT,
        };
    -   
    -   hal_dma_init(DMA_CH_4, &dma_init);
    -   hal_dma_en(DMA_CH_4, HAL_DISABLE);
    -}
     
    +   hal_dma_init(DMA_CH_2, &dma_init);
    +   hal_dma_en(DMA_CH_2, HAL_DISABLE);
    +}
     void SPIDMA_StartTX(struct spi_message* msg)
     {
    -   hal_dma_set_mem_addr(DMA_CH_4, (uint32_t)msg->send_buf);
    -   hal_dma_set_data_num(DMA_CH_4, msg->send_len);
    -
    -   hal_spi_dma_en(SPI0_BASE, SPI_DMA_TX_EN, HAL_ENABLE);
    -   hal_dma_en(DMA_CH_4, HAL_ENABLE);
    -   
    -   while(hal_dma_get_data_num(DMA_CH_4) != 0);
    -   
    -   hal_dma_en(DMA_CH_4, HAL_DISABLE);
    -   hal_spi_dma_en(SPI0_BASE, SPI_DMA_TX_EN, HAL_DISABLE);
    +   hal_dma_set_mem_addr(DMA_CH_2, (uint32_t)msg->send_buf);
    +   hal_dma_set_data_num(DMA_CH_2, msg->send_len);
    +
    +   hal_dma_en(DMA_CH_2, HAL_ENABLE);
    +
    +   while(hal_dma_get_data_num(DMA_CH_2) != 0);
    +
    +   hal_dma_en(DMA_CH_2, HAL_DISABLE);
     }
     
     void SPIDMA_StopTX(void)
    


    The best native support is in new ameba chips.
    Just set T0H and other values, and there you go.
    https://github.com/Ameba-AIoT/ameba-rtos/blob...aw_ledc_ws2812/example_raw_ledc_ws2812.c#L206
  • #174 21630636
    p.kaczmarek2
    Moderator Smart Home
    Nice, realtek? Well we need SPI LED entry for platforms.md
    Helpful post? Buy me a coffee.
  • #175 21630637
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Well we need SPI LED entry for platforms.md

    and powersave I reckon

    Added after 1 [minutes]:

    if you're in the mood for adding variants to releases, BL602 1MB?
  • #176 21630916
    p.kaczmarek2
    Moderator Smart Home
    And again... it seems fixing merge conflicts in Visual Code breaks indent? Very strange. I will discard this file and take it from main.
    Changes in obk_config.h file showing removed and added preprocessor defines
    Helpful post? Buy me a coffee.
  • #177 21630951
    insmod
    Level 27  
    >>21630916
    Ident is already broken in main.
    I re-idented everything in spi led pull request.
    It's merge ready.
    I won't do realtek spi led in that one, if i do - it will be in a separate pull req. Current problem is that DMA requires offsets and length to be aligned to 32 bits.
    I probably won't for some time, i'm waiting for BW15 dev board.

    I use VSCodium for merge conflict resolution, it works fine (at least for me).
    P.S. do you think we should adopt LED timings/frequency from https://github.com/esphome/esphome/blob/maste...e/components/beken_spi_led_strip/light.py#L45

    Added after 39 [minutes]:

    @p.kaczmarek2
    ENABLE_DRIVER_PINMUTEX define was removed when led was merged.
  • #178 21631068
    p.kaczmarek2
    Moderator Smart Home
    Merged, thank you.

    Maybe not "adopt from there", but just add option for custom timings, I have bought some strips with different formats than WS2812, but didn't have time to play around with them yet.

    Are other PRs ready to merge?
    Helpful post? Buy me a coffee.
  • Helpful post
    #179 21631118
    insmod
    Level 27  
    >>21631068
    This one: https://github.com/openshwprojects/OpenBK7231T_App/pull/1743
    I will adjust new realteks later (will add easyflash, instead of current vfs).

    Tried WPA3 on WRG1.
    It connects, but doesn't receive ip / disconnects. With static ip - it connects, but inaccessible. On first attempt - always disconnects.
    Perhaps it is a problem with my test ap, i don't know. (on BPI-R4 + BE14000)
  • #180 21631157
    divadiow
    Level 35  
    Hmm ok. I can redo any if you have doubts about recent result table update. AmebaZ for eg

Topic summary

The discussion centers on configuring OpenBeken firmware for ESP32 devices with a default 4MB flash size using sdkconfig.defaults.esp32. Initial issues included missing sdkconfig.defaults.esp32 and bootloader offset misconfiguration, which were resolved to enable successful compilation and flashing. Various ESP32 variants were tested, including ESP32-C3, ESP32-C6, ESP32-CAM, ESP32-C2, ESP32-D0WDQ5-V3 (ESP-WROOM-32), and ESP32-S3, with reports on flash size detection, bootloader behavior, and peripheral support. Challenges encountered involved stack overflows on reboot, watchdog timer resets, and GPIO functionality inconsistencies, particularly on non-C/S ESP32 boards. Solutions included adjusting makefiles for 4MB flash, fixing bootloader offsets, increasing task stack sizes, and replacing software timers with hardware timers for improved timing accuracy. Peripheral drivers such as BMP280, AHT2x, DS1820, DHT11/22, PWM, UART, and NTP were tested with varying success; some required specific pin assignments or additional delays to prevent crashes. Deep sleep support was added without GPIO wakeup. The firmware uses the Espressif ESP-IDF SDK for ESP32 and plans for ESP8266 porting were discussed, noting SDK differences and RAM constraints. Continuous integration (CI) and online build availability were confirmed. Users shared flashing tools, partition table considerations, and debugging tips including esptool flash_id and efuse burning. The community actively tested and reported logs, crashes, and feature functionality, contributing to iterative fixes and enhancements.
Summary generated by the language model.
ADVERTISEMENT