summaryrefslogtreecommitdiff
path: root/ports/esp32s2
diff options
context:
space:
mode:
authordherrada <33632497+dherrada@users.noreply.github.com>2020-07-17 14:55:30 -0400
committerGitHub <noreply@github.com>2020-07-17 14:55:30 -0400
commit612c6bb86b8762aa9388566eb69db9bbe4e8bbe4 (patch)
treee6fed04531c6772ea4724a75e3a88b8521e60703 /ports/esp32s2
parentd64b4e305929ccb68e0cf1ef977f42e213023f3b (diff)
parent88d89563783771daba2973eb8dc3faa237ba4b62 (diff)
Merge branch 'main' into type_hints
Diffstat (limited to 'ports/esp32s2')
-rw-r--r--ports/esp32s2/Makefile24
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Processor.c22
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Processor.h2
-rw-r--r--ports/esp32s2/fatfs_port.c2
-rw-r--r--ports/esp32s2/mpconfigport.mk2
-rw-r--r--ports/esp32s2/supervisor/internal_flash.c2
-rw-r--r--ports/esp32s2/supervisor/internal_flash.h2
7 files changed, 43 insertions, 13 deletions
diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile
index 3e69e6639..29abcab8e 100644
--- a/ports/esp32s2/Makefile
+++ b/ports/esp32s2/Makefile
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -217,8 +217,8 @@ $(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig | $(BUILD)/esp-id
# build a lib
# Adding -d explain -j 1 -v to the ninja line will output debug info
-$(BUILD)/esp-idf/esp-idf/%.a: $(BUILD)/esp-idf/config/sdkconfig.h
- ninja -C $(BUILD)/esp-idf esp-idf/$*.a
+#$(BUILD)/esp-idf/esp-idf/%.a: $(BUILD)/esp-idf/config/sdkconfig.h
+# ninja -C $(BUILD)/esp-idf esp-idf/$*.a
$(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld: $(BUILD)/esp-idf/config/sdkconfig.h
ninja -C $(BUILD)/esp-idf esp-idf/esp32s2/esp32s2_out.ld
@@ -230,9 +230,6 @@ $(BUILD)/esp-idf/esp-idf/esp32s2/ld/esp32s2.project.ld: $(BUILD)/esp-idf/config/
$(BUILD)/esp-idf/partition_table/partition-table.bin: $(BUILD)/esp-idf/config/sdkconfig.h
IDF_PATH=$(IDF_PATH) ninja -C $(BUILD)/esp-idf partition_table/partition-table.bin
-$(BUILD)/esp-idf/bootloader/bootloader.bin: $(BUILD)/esp-idf/config/sdkconfig.h
- ninja -C $(BUILD)/esp-idf bootloader/bootloader.bin
-
# run menuconfig
menuconfig: $(BUILD)/esp-idf/config
ninja -C $(BUILD)/esp-idf menuconfig
@@ -260,7 +257,18 @@ FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
-$(BUILD)/firmware.elf: $(OBJ) | $(ESP_IDF_COMPONENTS_EXPANDED) $(ESP_AUTOGEN_LD)
+.PHONY: esp-idf-stamp
+esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
+ ninja -C $(BUILD)/esp-idf \
+ bootloader/bootloader.bin \
+ esp-idf/bootloader_support/libbootloader_support.a \
+ esp-idf/esp32s2/ld/esp32s2.project.ld \
+ esp-idf/esp_system/libesp_system.a \
+ esp-idf/freertos/libfreertos.a \
+ esp-idf/log/liblog.a \
+ esp-idf/xtensa/libxtensa.a
+
+$(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
$(STEPECHO) "LINK $@"
$(Q)$(CC) -o $@ $(LDFLAGS) $^ $(ESP_IDF_COMPONENTS_EXPANDED) $(BINARY_BLOBS) build-$(BOARD)/esp-idf/esp-idf/newlib/libnewlib.a -u newlib_include_pthread_impl
# $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld
@@ -271,7 +279,7 @@ $(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf
# $(Q)$(OBJCOPY) -O binary $^ $@
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
-$(BUILD)/firmware.bin: $(BUILD)/esp-idf/partition_table/partition-table.bin $(BUILD)/esp-idf/bootloader/bootloader.bin $(BUILD)/circuitpython-firmware.bin
+$(BUILD)/firmware.bin: $(BUILD)/circuitpython-firmware.bin | esp-idf-stamp
$(Q)$(PYTHON) ../../tools/join_bins.py $@ 0x1000 $(BUILD)/esp-idf/bootloader/bootloader.bin 0x8000 $(BUILD)/esp-idf/partition_table/partition-table.bin 0x10000 $(BUILD)/circuitpython-firmware.bin
$(BUILD)/firmware.uf2: $(BUILD)/circuitpython-firmware.bin
diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.c b/ports/esp32s2/common-hal/microcontroller/Processor.c
index 8eaf1a33d..39b85a18b 100644
--- a/ports/esp32s2/common-hal/microcontroller/Processor.c
+++ b/ports/esp32s2/common-hal/microcontroller/Processor.c
@@ -26,10 +26,14 @@
*/
#include <math.h>
+#include <string.h>
+
#include "common-hal/microcontroller/Processor.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
+#include "soc/efuse_reg.h"
+
float common_hal_mcu_processor_get_temperature(void) {
return NAN;
}
@@ -42,5 +46,23 @@ uint32_t common_hal_mcu_processor_get_frequency(void) {
return 0;
}
+STATIC uint8_t swap_nibbles(uint8_t v) {
+ return ((v << 4) | (v >> 4)) & 0xff;
+}
+
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
+ memset(raw_id, 0, COMMON_HAL_MCU_PROCESSOR_UID_LENGTH);
+
+ uint8_t *ptr = &raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH-1];
+ // MAC address contains 48 bits (6 bytes), 32 in the low order word
+ uint32_t mac_address_part = REG_READ(EFUSE_RD_MAC_SPI_SYS_0_REG);
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff);
+
+ // and 16 in the high order word
+ mac_address_part = REG_READ(EFUSE_RD_MAC_SPI_SYS_1_REG);
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff);
}
diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.h b/ports/esp32s2/common-hal/microcontroller/Processor.h
index a2ea261c8..f6636b333 100644
--- a/ports/esp32s2/common-hal/microcontroller/Processor.h
+++ b/ports/esp32s2/common-hal/microcontroller/Processor.h
@@ -27,7 +27,7 @@
#ifndef MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
#define MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
-#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 15
+#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 6
#include "py/obj.h"
diff --git a/ports/esp32s2/fatfs_port.c b/ports/esp32s2/fatfs_port.c
index 13ac21fb1..8bdc047c1 100644
--- a/ports/esp32s2/fatfs_port.c
+++ b/ports/esp32s2/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk
index 5686579b4..713ccbb09 100644
--- a/ports/esp32s2/mpconfigport.mk
+++ b/ports/esp32s2/mpconfigport.mk
@@ -7,7 +7,7 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
INTERNAL_LIBM = 1
# Chip supplied serial number, in bytes
-USB_SERIAL_NUMBER_LENGTH = 30
+USB_SERIAL_NUMBER_LENGTH = 12
# Longints can be implemented as mpz, as longlong, or not
LONGINT_IMPL = MPZ
diff --git a/ports/esp32s2/supervisor/internal_flash.c b/ports/esp32s2/supervisor/internal_flash.c
index 5cf77c801..26774efac 100644
--- a/ports/esp32s2/supervisor/internal_flash.c
+++ b/ports/esp32s2/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/esp32s2/supervisor/internal_flash.h b/ports/esp32s2/supervisor/internal_flash.h
index e06ef2d16..02d519003 100644
--- a/ports/esp32s2/supervisor/internal_flash.h
+++ b/ports/esp32s2/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy