Skip to content

Commit 42a5ffc

Browse files
committed
Modify HSDK to release candidate
Add generating files for u-boot update Add some packages to defconfig
1 parent 87157a0 commit 42a5ffc

File tree

56 files changed

+8907
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+8907
-9
lines changed

board/synopsys/hsdk/genimage.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ image boot.vfat {
22
vfat {
33
files = {
44
"uboot.env",
5-
"uImage"
5+
"uImage",
6+
"u-boot",
7+
"u-boot.head",
8+
"hsdk.dtb"
69
}
710
}
811
size = 100M

board/synopsys/hsdk/headerise.py

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import os, getopt, sys, zlib
2+
#we can use binascii instead of zlib
3+
4+
def usage(exit_code):
5+
print("usage:")
6+
print(sys.argv[0] + " --arc-id 0x52 --image u-boot.bin --elf u-boot")
7+
sys.exit(exit_code)
8+
9+
def main():
10+
try:
11+
opts, args = getopt.getopt(sys.argv[1:],
12+
"ha:i:l:e:", ["help", "arc-id=", "image=", "elf=", "env="])
13+
except getopt.GetoptError as err:
14+
print(err)
15+
usage(2)
16+
17+
# default filenames
18+
uboot_bin_filename = "u-boot.bin"
19+
uboot_elf_filename = "u-boot"
20+
headerised_filename = "u-boot.head"
21+
uboot_default_env = "u-boot-env.txt"
22+
uboot_patched_env = "u-boot-p-env.txt"
23+
24+
# initial header values
25+
arc_id = 0x52
26+
uboot_img_size = 0x0497fc
27+
check_sum = 0x61
28+
image_copy_adr = 0x81000000
29+
magic1 = 0xdeadbeafaf # big endian byte order
30+
jump_address = 0x81000000
31+
flash_address = 0x0
32+
flash_type = 0x0 # 0 - SPI flash, 1 - NOR flash
33+
magic2 = [ # big endian byte order
34+
0x20202a2020202020202020202a20202020207c5c2e20202020202e2f7c20202020207c2d,
35+
0x2e5c2020202f2e2d7c20202020205c2020602d2d2d6020202f20202020202f205f202020,
36+
0x205f20205c20202020207c205f60712070205f207c2020202020272e5f3d2f205c3d5f2e,
37+
0x272020202020202020605c202f60202020202020202020202020206f2020202020202020]
38+
39+
for opt, arg in opts:
40+
if opt in ('-h', "--help"): usage(0)
41+
if opt in ('-a', "--arc-id"): arc_id = int(arg, 16)
42+
if opt in ('-i', "--image"): uboot_bin_filename = arg
43+
if opt in ('-l', "--elf"): uboot_elf_filename = arg
44+
if opt in ('-e', "--env"): uboot_default_env = arg
45+
46+
# verify args:
47+
if arc_id not in [0x52, 0x53]:
48+
print("unknown ARC ID: " + hex(arc_id))
49+
sys.exit(2)
50+
51+
if not os.path.isfile(uboot_bin_filename):
52+
print("uboot bin file not exists: " + uboot_bin_filename)
53+
sys.exit(2)
54+
55+
if not os.path.isfile(uboot_default_env):
56+
print("uboot defaul environment file not exists: " + uboot_default_env)
57+
sys.exit(2)
58+
59+
uboot_img_size = os.path.getsize(uboot_bin_filename)
60+
61+
# Calculate u-boot image check_sum: it is sum of all u-boot binary bytes
62+
with open(uboot_bin_filename, "rb") as file:
63+
ba = bytearray(file.read())
64+
check_sum = sum(ba) & 0xFF
65+
66+
# write header to file
67+
with open(headerised_filename, "wb") as file:
68+
file.write(arc_id.to_bytes(2, byteorder='little'))
69+
file.write(uboot_img_size.to_bytes(4, byteorder='little'))
70+
file.write(check_sum.to_bytes(1, byteorder='little'))
71+
file.write(image_copy_adr.to_bytes(4, byteorder='little'))
72+
file.write(magic1.to_bytes(5, byteorder='big'))
73+
file.write(jump_address.to_bytes(4, byteorder='little'))
74+
for i in range(12): file.write(0xFF.to_bytes(1, byteorder='little'))
75+
for byte in magic2: file.write(byte.to_bytes(36, byteorder='big'))
76+
for i in range(208 - len(magic2) * 36):
77+
file.write(0xFF.to_bytes(1, byteorder='little'))
78+
file.write(flash_address.to_bytes(4, byteorder='little'))
79+
for i in range(11): file.write(0xFF.to_bytes(1, byteorder='little'))
80+
file.write(flash_type.to_bytes(1, byteorder='little'))
81+
82+
# append u-boot image to header
83+
with open(headerised_filename, "ab") as fo:
84+
with open(uboot_bin_filename,'rb') as fi:
85+
fo.write(fi.read())
86+
87+
# calc u-boot headerised image CRC32 (will be used by uboot update
88+
# command for check)
89+
headerised_image_crc = ""
90+
with open(headerised_filename, "rb") as fi:
91+
headerised_image_crc = hex(zlib.crc32(fi.read()) & 0xffffffff)
92+
print("image CRC32 = " + headerised_image_crc)
93+
94+
load_addr = 0x81000000
95+
load_size = os.path.getsize(headerised_filename)
96+
97+
# print("crc32 " + hex(load_addr) + " " + hex (load_size))
98+
99+
# make errase size to be allighned by 64K
100+
if load_size & 0xFFFF == 0:
101+
errase_size = load_size
102+
else:
103+
errase_size = load_size - (load_size & 0xFFFF) + 0x10000
104+
105+
# u-bood CMD to load u-bood with header to SPI flash
106+
sf_load_image_cmd = \
107+
"fatload mmc 0:1 " + hex(load_addr) + " " + headerised_filename + " && " + \
108+
"sf probe 0:0 && " + \
109+
"sf protect unlock 0x0 " + hex(errase_size) + " && " + \
110+
"sf erase 0x0 " + hex(errase_size) + " && " + \
111+
"sf write " + hex(load_addr) + " 0x0 " + hex(errase_size) + " && " + \
112+
"sf protect lock 0x0 " + hex(errase_size)
113+
114+
update_uboot_cmd = "update_uboot=" + \
115+
sf_load_image_cmd + " && echo \"u-boot update: OK\""
116+
117+
# append default environment with update commands
118+
with open(uboot_default_env, "rb") as fi:
119+
with open(uboot_patched_env, 'wb') as fo:
120+
fo.write(fi.read())
121+
fo.write(update_uboot_cmd.encode('ascii'))
122+
123+
124+
if __name__ == "__main__":
125+
main()
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
From 69175409cd952276c93653891da77fdb34aebc5e Mon Sep 17 00:00:00 2001
2+
From: Eugeniy Paltsev <[email protected]>
3+
Date: Fri, 22 Dec 2017 20:17:20 +0300
4+
Subject: [RFC] ARC: setup cpu possible mask according to status field in dts
5+
6+
As we have option in u-boot to set CPU mask for running linux,
7+
we want to pass information to kernel about CPU cores should
8+
be brought up.
9+
10+
So we patch kernel dtb in u-boot to set CPUs status.
11+
12+
On linux boot we setup cpu possible mask according to status
13+
field in each cpu node. It is generic method according to ePAPR:
14+
status - a standard property describing the state of a CPU.
15+
This property shall be present for nodes representing CPUs in a
16+
symmetric multiprocessing (SMP) configuration. For a CPU node
17+
the meaning of the "okay" and "disabled" values are as follows:
18+
"okay" - The CPU is running; "disabled" - The CPU is in a
19+
quiescent state."
20+
21+
Also we setup MCIP debug mask according cpu possible mask.
22+
23+
Signed-off-by: Eugeniy Paltsev <[email protected]>
24+
---
25+
arch/arc/kernel/mcip.c | 10 ++++++++--
26+
arch/arc/kernel/smp.c | 30 ++++++++++++++++++++++++++----
27+
2 files changed, 34 insertions(+), 6 deletions(-)
28+
29+
diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c
30+
index f61a52b..246481d 100644
31+
--- a/arch/arc/kernel/mcip.c
32+
+++ b/arch/arc/kernel/mcip.c
33+
@@ -89,6 +89,8 @@ static void mcip_ipi_clear(int irq)
34+
static void mcip_probe_n_setup(void)
35+
{
36+
struct mcip_bcr mp;
37+
+ u32 mcip_mask = 0;
38+
+ int i;
39+
40+
READ_BCR(ARC_REG_MCIP_BCR, mp);
41+
42+
@@ -102,9 +104,13 @@ static void mcip_probe_n_setup(void)
43+
44+
cpuinfo_arc700[0].extn.gfrc = mp.gfrc;
45+
46+
+ for (i = 0; i < NR_CPUS; i++)
47+
+ if (cpu_possible(i))
48+
+ mcip_mask |= BIT(i);
49+
+
50+
if (mp.dbg) {
51+
- __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf);
52+
- __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf);
53+
+ __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, mcip_mask);
54+
+ __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, mcip_mask);
55+
}
56+
}
57+
58+
diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
59+
index efe8b42..ee8b20a 100644
60+
--- a/arch/arc/kernel/smp.c
61+
+++ b/arch/arc/kernel/smp.c
62+
@@ -24,6 +24,8 @@
63+
#include <linux/reboot.h>
64+
#include <linux/irqdomain.h>
65+
#include <linux/export.h>
66+
+#include <linux/of_fdt.h>
67+
+#include <linux/libfdt.h>
68+
69+
#include <asm/processor.h>
70+
#include <asm/setup.h>
71+
@@ -47,6 +49,29 @@ void __init smp_prepare_boot_cpu(void)
72+
{
73+
}
74+
75+
+/* Mark cpu as possible if cpu status is "okay" or status absents */
76+
+void __init smp_init_cpumask(void)
77+
+{
78+
+ const struct fdt_property *prop;
79+
+ char fdt_cpu_path[25];
80+
+ unsigned int i, oft;
81+
+
82+
+ for (i = 0; i < NR_CPUS; i++) {
83+
+ sprintf(fdt_cpu_path, "/cpus/cpu@%u", i);
84+
+ oft = fdt_path_offset(initial_boot_params, fdt_cpu_path);
85+
+ prop = fdt_get_property(initial_boot_params, oft, "status", NULL);
86+
+
87+
+ /* No status property == status OK */
88+
+ if (!prop) {
89+
+ set_cpu_possible(i, true);
90+
+ continue;
91+
+ }
92+
+
93+
+ if (!strcmp("okay", prop->data))
94+
+ set_cpu_possible(i, true);
95+
+ }
96+
+}
97+
+
98+
/*
99+
* Called from setup_arch() before calling setup_processor()
100+
*
101+
@@ -58,10 +83,7 @@ void __init smp_prepare_boot_cpu(void)
102+
*/
103+
void __init smp_init_cpus(void)
104+
{
105+
- unsigned int i;
106+
-
107+
- for (i = 0; i < NR_CPUS; i++)
108+
- set_cpu_possible(i, true);
109+
+ smp_init_cpumask();
110+
111+
if (plat_smp_ops.init_early_smp)
112+
plat_smp_ops.init_early_smp();
113+
--
114+
2.9.3
115+

board/synopsys/hsdk/post-image.sh

100644100755
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
66
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
77
rm -rf "${GENIMAGE_TMP}"
88

9-
mv ${BINARIES_DIR}/uboot-env.bin ${BINARIES_DIR}/uboot.env
9+
python3 ${BOARD_DIR}/headerise.py --arc-id 0x52 --image output/images/u-boot.bin --elf output/images/u-boot --env ${BOARD_DIR}/uboot.env.txt
10+
mkenvimage -s 0x4000 -o output/images/uboot.env ./u-boot-p-env.txt
11+
cp ./u-boot.head output/images
12+
rm u-boot.head u-boot-p-env.txt
1013

1114
genimage \
1215
--rootpath "${TARGET_DIR}" \
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
From 0aa461be83200a1211d365c1c924bd94e1b5a0d6 Mon Sep 17 00:00:00 2001
2+
From: Eugeniy Paltsev <[email protected]>
3+
Date: Sat, 21 Oct 2017 15:02:44 +0300
4+
Subject: [PATCH 01/46] ARC: HSDK: Fixup DW SDIO CIU frequency to 50000000Hz
5+
6+
DW sdio controller has external ciu clock devider controlled via
7+
register in SDIO IP. Due to its unexpected default value
8+
(it should devide by 1 but it devides by 8)
9+
SDIO IP uses wrong CIU clock (it should be 100000000Hz but actual
10+
is 12500000Hz) and works unstable (see STAR 9001204800)
11+
12+
So increase SDIO CIU frequency from actual 12500000Hz to 50000000Hz
13+
by switching from the default divisor value (div-by-8) to the
14+
minimum possible value of the divisor (div-by-2) in HSDK platform
15+
code.
16+
17+
Signed-off-by: Eugeniy Paltsev <[email protected]>
18+
---
19+
board/synopsys/hsdk/hsdk.c | 12 +++++++++++-
20+
1 file changed, 11 insertions(+), 1 deletion(-)
21+
22+
diff --git a/board/synopsys/hsdk/hsdk.c b/board/synopsys/hsdk/hsdk.c
23+
index 7b562556e6..7641978a7b 100644
24+
--- a/board/synopsys/hsdk/hsdk.c
25+
+++ b/board/synopsys/hsdk/hsdk.c
26+
@@ -26,6 +26,10 @@ int board_early_init_f(void)
27+
return 0;
28+
}
29+
30+
+#define SDIO_BASE (ARC_PERIPHERAL_BASE + 0xA000)
31+
+#define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108)
32+
+#define SDIO_UHS_REG_EXT_DIV_2 (2 << 30)
33+
+
34+
int board_mmc_init(bd_t *bis)
35+
{
36+
struct dwmci_host *host = NULL;
37+
@@ -36,12 +40,18 @@ int board_mmc_init(bd_t *bis)
38+
return 1;
39+
}
40+
41+
+ /*
42+
+ * Switch SDIO external ciu clock divider from default div-by-8 to
43+
+ * minimum possible div-by-2.
44+
+ */
45+
+ writel(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT);
46+
+
47+
memset(host, 0, sizeof(struct dwmci_host));
48+
host->name = "Synopsys Mobile storage";
49+
host->ioaddr = (void *)ARC_DWMMC_BASE;
50+
host->buswidth = 4;
51+
host->dev_index = 0;
52+
- host->bus_hz = 100000000;
53+
+ host->bus_hz = 50000000;
54+
55+
add_dwmci(host, host->bus_hz / 2, 400000);
56+
57+
--
58+
2.11.0
59+

0 commit comments

Comments
 (0)