Skip to content

Commit a761354

Browse files
committed
platformio build system
1 parent 9a2430b commit a761354

File tree

4 files changed

+71
-10
lines changed

4 files changed

+71
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ modules.order
5050
Module.symvers
5151
Mkfile.old
5252
dkms.conf
53+
54+
.*/

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ high-speed either.
2424

2525
## Building
2626

27-
1. Install [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk)
28-
1. `sudo apt install esptool`
29-
1. Compile and flash
30-
31-
```
32-
ESP_OPEN_SDK=/opt/esp-open-sdk
33-
export XTENSA_TOOLS_ROOT=$ESP_OPEN_SDK/xtensa-lx106-elf/bin SDK_BASE=$ESP_OPEN_SDK/sdk flash
34-
make flash
35-
```
27+
- Use [Platformio](https://docs.platformio.org/en/stable/integration/ide/vscode.html) to easily build and flash ESP8266 from the VScode.
28+
29+
- Alternatively,
30+
1. Install [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk)
31+
1. `sudo apt install esptool`
32+
1. Compile and flash:
33+
34+
```
35+
ESP_OPEN_SDK=/opt/esp-open-sdk
36+
export XTENSA_TOOLS_ROOT=$ESP_OPEN_SDK/xtensa-lx106-elf/bin SDK_BASE=$ESP_OPEN_SDK/sdk flash
37+
make flash
38+
```
3639

3740
### Using a precompiled binary
3841

platformio.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:esp-stlink]
12+
platform = espressif8266
13+
board = d1_mini
14+
framework = esp8266-nonos-sdk
15+
build_flags = -I src/include
16+
monitor_speed = 921600

src/user/user_main.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,53 @@
1111
* You should have received a copy of the GNU General Public License along
1212
* with this program. If not, see <http://www.gnu.org/licenses/>.
1313
*/
14+
15+
#include "user_interface.h"
16+
1417
#include "driver/swim.h"
1518
#include "driver/uart.h"
1619
#include "serial.h"
1720

21+
uint32 ICACHE_FLASH_ATTR
22+
user_rf_cal_sector_set(void) {
23+
enum flash_size_map size_map = system_get_flash_size_map();
24+
uint32 rf_cal_sec = 0;
25+
26+
switch (size_map) {
27+
case FLASH_SIZE_4M_MAP_256_256:
28+
rf_cal_sec = 128 - 5;
29+
break;
30+
31+
case FLASH_SIZE_8M_MAP_512_512:
32+
rf_cal_sec = 256 - 5;
33+
break;
34+
35+
case FLASH_SIZE_16M_MAP_512_512:
36+
case FLASH_SIZE_16M_MAP_1024_1024:
37+
rf_cal_sec = 512 - 5;
38+
break;
39+
40+
case FLASH_SIZE_32M_MAP_512_512:
41+
case FLASH_SIZE_32M_MAP_1024_1024:
42+
rf_cal_sec = 1024 - 5;
43+
break;
44+
45+
case FLASH_SIZE_64M_MAP_1024_1024:
46+
rf_cal_sec = 2048 - 5;
47+
break;
48+
case FLASH_SIZE_128M_MAP_1024_1024:
49+
rf_cal_sec = 4096 - 5;
50+
break;
51+
default:
52+
rf_cal_sec = 0;
53+
break;
54+
}
55+
return rf_cal_sec;
56+
}
57+
1858
void user_init(void) {
1959
swim_init();
2060
uart_init(BIT_RATE_921600, BIT_RATE_921600);
21-
uart0_sendStr("ESP-STLINK\r\n");
61+
uart0_sendStr("\r\nESP-STLINK\r\n");
2262
serial_init();
2363
}

0 commit comments

Comments
 (0)