add a static library to main in project Mainfile

grooves
Posts: 12
Joined: Fri Aug 25, 2017 2:51 pm

add a static library to main in project Mainfile

Postby grooves » Thu Sep 28, 2017 10:53 am

Hi folk,

how can I add and link an existing static library file .a to main project ?
I have a huge libwebpages-espfs.a file which contains html files packed in espfs filesystem,
comes from awesome Sprites ESP8266 HTTPD project.
I'm working on a portation to ESP-IDF and it works already well with hardcoded flash adresses.
next step will be to have filesystem on flexible addresses.
but I can't find a way to add the file to linker script

Thanks for help,
Grooves

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: add a static library to main in project Mainfile

Postby ESP_Sprite » Thu Sep 28, 2017 1:35 pm

You may actually be better off using the esp-idf branch of libesphttpd instead: that's already mostly adapted to the ESP32.

grooves
Posts: 12
Joined: Fri Aug 25, 2017 2:51 pm

Re: add a static library to main in project Mainfile

Postby grooves » Thu Sep 28, 2017 4:26 pm

Many thanks, that is exactly I was looking for, saves my time, :-)

did just some minor changes to be able to compile it as component in IDF 3.0

in httpdesps.h
+++#include "platform.h"

in platform.h
---typedef *HttpdPlatTimer HttpdPlatTimerHandle;
+++typedef HttpdPlatTimer* HttpdPlatTimerHandle;

in cgiflash.c
comment out weird lines:
//<<<<<<< HEAD
//esp32flashSetOtaAsCurrentImage();
//=======
esp32flashSetOtaAsCurrentImage();
//>>>>>>> c08b304e8b907287af7580510db4c6323eeb052c

Regards,
Grooves

grooves
Posts: 12
Joined: Fri Aug 25, 2017 2:51 pm

Re: add a static library to main in project Mainfile

Postby grooves » Fri Sep 29, 2017 2:46 pm

Hi Sprite,

is it correct, the esp-idf branch for ESP32 doesn't support the OTA update via httpd flash page yet ?
I can't find howto build user1.bin/user2.bin

Regards,
Grooves

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: add a static library to main in project Mainfile

Postby ESP_Sprite » Sat Sep 30, 2017 1:01 am

I think it does, but because the ESP32 has an MMU, user1/user2.bin are supperfluous. You should be able to just upload your build/<appname>.bin file.

grooves
Posts: 12
Joined: Fri Aug 25, 2017 2:51 pm

Re: add a static library to main in project Mainfile

Postby grooves » Thu Oct 05, 2017 3:52 pm

I see, due to MMU it is always mapped to the same virtual addresses,
I tried to download just the build.bin file and got some errors:
I don't know which one is important

...
Firmware upload cgi start.
checkBinHeader: e9 4008 3f400020
esp32 ota: no valid ota select sector found!
OTA part select ID: -1
Writing 4096 bytes of data to SPI pos 0xff000000...
Writing 4096 bytes of data to SPI pos 0xff001000...
....
Writing 736 bytes of data to SPI pos 0xff09c000...
Upload done. Sending response.
esp32 ota: no valid ota select sector found!
OTA part select ID: -1
esp32 ota: no valid ota select sector found!
Writing seq 1 to ota select sector 2
....
after reboot

E (9) esp_image: image at 0x210000 has invalid magic byte
W (9) esp_image: image at 0x210000 has invalid SPI mode 255
W (10) esp_image: image at 0x210000 has invalid SPI size 15
E (16) boot: OTA app partition slot 1 is not bootable
E (22) esp_image: image at 0x110000 has invalid magic byte
W (28) esp_image: image at 0x110000 has invalid SPI mode 255
W (34) esp_image: image at 0x110000 has invalid SPI size 15
E (40) boot: OTA app partition slot 0 is not bootable
I (177) cpu_start: Pro cpu up.

my partition table looks like this:

Partition table binary generated. Contents:
*******************************************************************************
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
ota_0,app,ota_0,0x110000,1M,
ota_1,app,ota_1,0x210000,1M,
*******************************************************************************

Thanks for any help,
Grooves

grooves
Posts: 12
Joined: Fri Aug 25, 2017 2:51 pm

Re: add a static library to main in project Mainfile

Postby grooves » Thu Oct 05, 2017 4:57 pm

Is it correct that you are looking for data partitions ?

esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);

I use the predefined partitiontable from menuconfig which generates two OTA app partitions

Regards,
Grooves

grooves
Posts: 12
Joined: Fri Aug 25, 2017 2:51 pm

Re: add a static library to main in project Mainfile

Postby grooves » Fri Oct 06, 2017 3:04 pm

Hi Sprite,

now I understand more what your code does:
esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);

is correct, you check if there is already a OTA selected partition.
The problem was, when there on OTA select partition (after make erase_flash),
the function selectedPart=getOtaSel() returns with -1.

then in esp32flashGetUpdateMem

if (selectedPart==-1) return 0;
it leads that address and size are not initalized.

I changed to:
if (selectedPart==-1) selectedPart = 1; //return 0;

and everything works fine, :-)

Thanks again,
Grooves

Who is online

Users browsing this forum: No registered users and 171 guests