Skip to content

Commit 9427c4c

Browse files
committed
modify for bch
1 parent 2a46898 commit 9427c4c

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

storage/blockdevice/COMPONENT_SPINAND/source/SPINANDBlockDevice.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,12 @@ bool SPINANDBlockDevice::_read_otp_onfi()
707707
_ecc_bits = onfi_table[112];
708708
if (_ecc_bits > 0) {
709709
_bch_init(_ecc_bits);
710+
secur_reg &= ~SPINAND_SECURE_BIT_ECC_EN;
711+
712+
if (QSPI_STATUS_OK != _qspi_send_general_command(SPINAND_INST_SET_FEATURE, FEATURES_ADDR_SECURE_OTP,
713+
(char *) &secur_reg, 1, NULL, 0)) {
714+
tr_error("Writing Register failed");
715+
}
710716
} else {
711717
secur_reg |= SPINAND_SECURE_BIT_ECC_EN;
712718

storage/blockdevice/COMPONENT_SPINAND/source/bch.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,22 @@ void encode_bch(struct bch_control *bch, const uint8_t *data,
267267

268268
for (i = 0; i < l; i++) {
269269
r[i] = r[i + 1] ^ p0[i] ^ p1[i] ^ p2[i] ^ p3[i];
270-
r[l] = p0[l] ^ p1[l] ^ p2[l] ^ p3[l];
270+
271271
}
272-
memcpy(bch->ecc_buf, r, sizeof(r));
272+
r[l] = p0[l] ^ p1[l] ^ p2[l] ^ p3[l];
273+
}
274+
memcpy(bch->ecc_buf, r, sizeof(r));
273275

274-
/* process last unaligned bytes */
275-
if (len) {
276-
encode_bch_unaligned(bch, data, len, bch->ecc_buf);
277-
}
276+
/* process last unaligned bytes */
277+
if (len) {
278+
encode_bch_unaligned(bch, data, len, bch->ecc_buf);
279+
}
278280

279-
/* store ecc parity bytes into original parity buffer */
280-
if (ecc) {
281-
store_ecc8(bch, ecc, bch->ecc_buf);
282-
}
281+
/* store ecc parity bytes into original parity buffer */
282+
if (ecc) {
283+
store_ecc8(bch, ecc, bch->ecc_buf);
283284
}
285+
284286
}
285287

286288
static inline int modulo(struct bch_control *bch, unsigned int v)

targets/targets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4403,7 +4403,7 @@
44034403
"STM32L4R9xI"
44044404
],
44054405
"components_add": [
4406-
"FLASHIAP"
4406+
44074407
],
44084408
"macros_add": [
44094409
"STM32L4R9xx"
@@ -4423,7 +4423,7 @@
44234423
"MX25LM51245G"
44244424
],
44254425
"components_add": [
4426-
"OSPIF"
4426+
"SPINAND"
44274427
],
44284428
"macros_add": [
44294429
"HSE_VALUE=16000000"

0 commit comments

Comments
 (0)