Fix issues with json files
File parsing no longer uses istream, which strips whitespace. Moved hard-coded json to its own file.
Signed-off-by: Alexander Yee <xander.yee@gmail.com>
Change-Id: I342b74fd1cc8c5af7721af5955aa7d7b185ac71e
diff --git a/aos/starter/BUILD b/aos/starter/BUILD
index 5690bda..8d3f4f5 100644
--- a/aos/starter/BUILD
+++ b/aos/starter/BUILD
@@ -226,6 +226,9 @@
srcs = [
"irq_affinity.cc",
],
+ data = [
+ "//aos/starter:rockpi_config.json",
+ ],
visibility = ["//visibility:public"],
deps = [
":irq_affinity_lib",
diff --git a/aos/starter/irq_affinity.cc b/aos/starter/irq_affinity.cc
index 3f32ec9..5c70e9e 100644
--- a/aos/starter/irq_affinity.cc
+++ b/aos/starter/irq_affinity.cc
@@ -14,6 +14,8 @@
DEFINE_string(user, "",
"Starter runs as though this user ran a SUID binary if set.");
+DEFINE_string(irq_config, "rockpi_config.json",
+ "File path of rockpi configuration");
namespace aos {
@@ -265,117 +267,10 @@
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
aos::configuration::ReadConfig(FLAGS_config);
- // TODO(austin): File instead of hard-coded JSON.
aos::FlatbufferDetachedBuffer<aos::starter::IrqAffinityConfig>
irq_affinity_config =
- aos::JsonToFlatbuffer<aos::starter::IrqAffinityConfig>(
- R"json({
- "irqs": [
- {
- "name": "ttyS2",
- "affinity": [1]
- },
- {
- "name": "dw-mci",
- "affinity": [1]
- },
- {
- "name": "mmc1",
- "affinity": [1]
- },
- {
- "name": "rkisp1",
- "affinity": [2]
- },
- {
- "name": "ff3c0000.i2c",
- "affinity": [2]
- },
- {
- "name": "ff3d0000.i2c",
- "affinity": [2]
- },
- {
- "name": "ff6e0000.dma-controller",
- "affinity": [0]
- },
- {
- "name": "ff1d0000.spi",
- "affinity": [0]
- },
- {
- "name": "eth0",
- "affinity": [1]
- }
- ],
- "kthreads": [
- {
- "name": "irq/*-ff940000.hdmi",
- "scheduler": "SCHEDULER_OTHER"
- },
- {
- "name": "irq/*-rockchip_usb2phy",
- "scheduler": "SCHEDULER_OTHER"
- },
- {
- "name": "irq/*-mmc0",
- "scheduler": "SCHEDULER_OTHER"
- },
- {
- "name": "irq/*-mmc1",
- "scheduler": "SCHEDULER_OTHER"
- },
- {
- "name": "irq/*-fe320000.mmc cd",
- "scheduler": "SCHEDULER_OTHER"
- },
- {
- "name": "irq/*-vc4 crtc",
- "scheduler": "SCHEDULER_OTHER"
- },
- {
- "name": "irq/*-rkisp1",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 60,
- "affinity": [2]
- },
- {
- "name": "irq/*-ff3c0000.i2c",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 51,
- "affinity": [2]
- },
- {
- "name": "irq/*-adis16505",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 59,
- "affinity": [0]
- },
- {
- "name": "irq/*-ff6e0000.dma-controller",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 59,
- "affinity": [0]
- },
- {
- "name": "spi0",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 57,
- "affinity": [0]
- },
- {
- "name": "irq/*-eth0",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 10,
- "affinity": [1]
- },
- {
- "name": "irq/*-rockchip_thermal",
- "scheduler": "SCHEDULER_FIFO",
- "priority": 1
- }
- ]
-})json");
+ aos::JsonFileToFlatbuffer<aos::starter::IrqAffinityConfig>(
+ FLAGS_irq_config);
aos::ShmEventLoop shm_event_loop(&config.message());
diff --git a/aos/starter/rockpi_config.json b/aos/starter/rockpi_config.json
new file mode 100644
index 0000000..d4cbaae
--- /dev/null
+++ b/aos/starter/rockpi_config.json
@@ -0,0 +1,107 @@
+{
+ "irqs": [
+ {
+ "name": "ttyS2",
+ "affinity": [1]
+ },
+ {
+ "name": "dw-mci",
+ "affinity": [1]
+ },
+ {
+ "name": "mmc1",
+ "affinity": [1]
+ },
+ {
+ "name": "rkisp1",
+ "affinity": [2]
+ },
+ {
+ "name": "ff3c0000.i2c",
+ "affinity": [2]
+ },
+ {
+ "name": "ff3d0000.i2c",
+ "affinity": [2]
+ },
+ {
+ "name": "ff6e0000.dma-controller",
+ "affinity": [0]
+ },
+ {
+ "name": "ff1d0000.spi",
+ "affinity": [0]
+ },
+ {
+ "name": "eth0",
+ "affinity": [1]
+ }
+ ],
+ "kthreads": [
+ {
+ "name": "irq/*-ff940000.hdmi",
+ "scheduler": "SCHEDULER_OTHER"
+ },
+ {
+ "name": "irq/*-rockchip_usb2phy",
+ "scheduler": "SCHEDULER_OTHER"
+ },
+ {
+ "name": "irq/*-mmc0",
+ "scheduler": "SCHEDULER_OTHER"
+ },
+ {
+ "name": "irq/*-mmc1",
+ "scheduler": "SCHEDULER_OTHER"
+ },
+ {
+ "name": "irq/*-fe320000.mmc cd",
+ "scheduler": "SCHEDULER_OTHER"
+ },
+ {
+ "name": "irq/*-vc4 crtc",
+ "scheduler": "SCHEDULER_OTHER"
+ },
+ {
+ "name": "irq/*-rkisp1",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 60,
+ "affinity": [2]
+ },
+ {
+ "name": "irq/*-ff3c0000.i2c",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 51,
+ "affinity": [2]
+ },
+ {
+ "name": "irq/*-adis16505",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 59,
+ "affinity": [0]
+ },
+ {
+ "name": "irq/*-ff6e0000.dma-controller",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 59,
+ "affinity": [0]
+ },
+ {
+ "name": "spi0",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 57,
+ "affinity": [0]
+ },
+ {
+ "name": "irq/*-eth0",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 10,
+ "affinity": [1]
+ },
+ {
+ "name": "irq/*-rockchip_thermal",
+ "scheduler": "SCHEDULER_FIFO",
+ "priority": 1
+ }
+ ]
+}