AXP2101 PMU eFuse configuration after replacement – help needed

I was in the same situation, accidentally inserted my battery in reverse and killed AXP2101. I replaced it with the one I bought on aliexpress, but my LCD was not comming up after this replacement. Then I found this thread and thanks to the dump of orginal values of the stock AXP registers provided by @cathiele I was able to fix it. I used @JackCarterSmith rewrite of the picocalc BIOS described here:

GIT:

What I basically did is:

modified Src/axp2101.c file and added:

#define AXPI2C_RETRIES 3
#define AXPI2C_TIMEOUT_MS 100

typedef struct {
    uint8_t reg;
    uint8_t val;
} reg_pair_t;

static const reg_pair_t axp_init[] = {
    {0x12,0x00},
    {0x22,0x04},
    {0x24,0x00},
    {0x25,0x19},
    {0x27,0x16},
    {0x58,0x00},
    {0x50,0x12},
    {0x62,0x13},
    {0x69,0x01},
    {0x80,0x01},
    {0x82,0x12},
    {0x83,0x00},
    {0x84,0x00},
    {0x85,0x00},
    {0x90,0x3F},
    {0x91,0x00},
    {0x92,0x1C},
    {0x93,0x1C},
    {0x94,0x1C},
    {0x95,0x1C},
    {0x96,0x1E},
    {0x97,0x1E},
    {0x98,0x00},
    {0x99,0x00},
    {0x9A,0x00},
};


static HAL_StatusTypeDef axp2101_write_reg(uint8_t reg, uint8_t val)
{
    HAL_StatusTypeDef ret;
    for (int attempt = 0; attempt < AXPI2C_RETRIES; ++attempt) {
        ret = HAL_I2C_Mem_Write(&hi2c2,  AXP2101_DEV_I2C_ID, reg, I2C_MEMADD_SIZE_8BIT, &val, 1, AXPI2C_TIMEOUT_MS);
        if (ret == HAL_OK) return HAL_OK;
        HAL_Delay(5);
    }
    return ret;
}



int axp2101_init_regs(void)
{
    size_t n = sizeof(axp_init)/sizeof(axp_init[0]);
    for (size_t i = 0; i < n; ++i) {
        HAL_StatusTypeDef s = axp2101_write_reg(axp_init[i].reg, axp_init[i].val);
        if (s != HAL_OK) {
            // TODO: error handle
            return -1;
        }
    }
    return 0;
}

modified Inc/axp2101.h and added function declaration:

int axp2101_init_regs(void);

and then modified main.c file and added the following after AXP initialization in main() (after line 195)

            if (axp2101_init_regs() != 0) {
                    // TODO: error handling
            }

and BUM, it works! Maybe this will help you as well.

2 Likes