基于VSCode的ESP32开发环境的搭建
esp-aliyun
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
ota_0,app,ota_0,0x10000,1M,
ota_1,app,ota_1,0x110000,1M,
fctry,data,nvs,0x210000,16K,
*******************************************************************************
要注意最后一个
fctry,data,nvs,0x210000,16K,
阿里云的设备是一机一码的,到时候我们需要将阿里云设备的四元组烧录到0x210000地址里面
将…components\esptool_py\esptool\esptool.py更换成你的位置
python D:\APP\esp_idf_tools\.espressif\frameworks\esp-idf-v4.4\components\esptool_py\esptool\esptool.py erase_flash
注意:erase_flash是擦除整片flash,你在上面保存得四元组/wifi的账号密码都会被擦除
没有烧录四元组就会报 wrapper_product: HAL_GetProductParam nvs_open failed with 1102 错误
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py 修改成自己的目录位置
python D:/APP/esp_idf_tools/.espressif/frameworks/esp-idf-v4.4/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate single_mfg_config.csv single_mfg.bin 0x4000
components\esptool_py\esptool\esptool.py 修改成自己的目录位置
python D:\APP\esp_idf_tools\.espressif\frameworks\esp-idf-v4.4\components\esptool_py\esptool\esptool.py write_flash 0x210000 single_mfg.bin
如果你觉得上面的四元组生成bin,再烧录很麻烦,可以试试下面这个方法(适合调试使用,不适合量产)
// 产品设备信息设置函数声明
int HAL_SetProductKey(char *product_key);
int HAL_SetProductSecret(char *product_secret);
int HAL_SetDeviceName(char *device_name);
int HAL_SetDeviceSecret(char *device_secret);
void app_main()
{
{// 代码中配置产品设备信息,用于调试
HAL_SetProductKey("*********");
HAL_SetProductSecret("************");
HAL_SetDeviceName("**************");
HAL_SetDeviceSecret("*****************************");
}
}
注意:一定要选择"一键配网",否则会一直在扫描通道,无法配网
[crt] zconfig_get_ssid_passwd(326): SSID1: [*******]
[crt] zconfig_get_ssid_passwd(362): passwd err
解决方法:检测清楚你的四元组是否正确
void app_main()
{
{ // 设置wifi账号密码
const char *ssid = "*************";
const char *password = "*****************";
conn_mgr_set_wifi_config_ext((const uint8_t *)ssid, strlen(ssid), (const uint8_t *)password, strlen(password));
}
}
待续…