|
11 | 11 | #include "hal/efuse_hal.h"
|
12 | 12 | #include "hal/efuse_ll.h"
|
13 | 13 | #include "esp32s3/rom/efuse.h"
|
| 14 | +#include "esp_attr.h" |
14 | 15 |
|
15 | 16 | #define ESP_EFUSE_BLOCK_ERROR_BITS(error_reg, block) ((error_reg) & (0x0F << (4 * (block))))
|
16 | 17 |
|
17 |
| -uint32_t efuse_hal_get_major_chip_version(void) |
| 18 | + |
| 19 | +//The wafer_major and MSB of wafer_minor fields was allocated to other purposes when block version is v1.1. |
| 20 | +//Luckily only chip v0.0 have this kind of block version and efuse usage. |
| 21 | +//This workaround fixes the issue. |
| 22 | +static inline bool is_eco0(uint32_t minor_raw) |
| 23 | +{ |
| 24 | + return ((minor_raw & 0x7) == 0 && |
| 25 | + efuse_ll_get_blk_version_major() == 1 && efuse_ll_get_blk_version_minor() == 1); |
| 26 | +} |
| 27 | + |
| 28 | +IRAM_ATTR uint32_t efuse_hal_get_major_chip_version(void) |
18 | 29 | {
|
19 |
| - uint32_t ret = efuse_ll_get_chip_wafer_version_major(); |
20 |
| - //Workaround: The major version field was allocated to other purposes when block version is v1.1. |
21 |
| - //Luckily only chip v0.0 have this kind of block version and efuse usage. |
22 |
| - if (efuse_ll_get_chip_wafer_version_minor() == 0 && |
23 |
| - efuse_ll_get_blk_version_major() == 1 && |
24 |
| - efuse_ll_get_blk_version_minor() == 1) { |
25 |
| - ret = 0; |
| 30 | + uint32_t minor_raw = efuse_ll_get_chip_wafer_version_minor(); |
| 31 | + |
| 32 | + if (is_eco0(minor_raw)) { |
| 33 | + return 0; |
26 | 34 | }
|
27 |
| - return ret; |
| 35 | + return efuse_ll_get_chip_wafer_version_major(); |
28 | 36 | }
|
29 | 37 |
|
30 | 38 | uint32_t efuse_hal_get_minor_chip_version(void)
|
31 | 39 | {
|
32 |
| - return efuse_ll_get_chip_wafer_version_minor(); |
| 40 | + uint32_t minor_raw = efuse_ll_get_chip_wafer_version_minor(); |
| 41 | + |
| 42 | + if (is_eco0(minor_raw)) { |
| 43 | + return 0; |
| 44 | + } |
| 45 | + return minor_raw; |
33 | 46 | }
|
34 | 47 |
|
35 | 48 | /******************* eFuse control functions *************************/
|
|
0 commit comments