allwinner-a10: add config script support
PATCH 1/1 allwinner-a10: add config script support
sunxi-linux kernel parse config script
to do hardware configurations
--- hw/arm/allwinner-a10.c | 18 ++++++++++++++++++ hw/arm/cubieboard.c | 2 ++ include/hw/arm/allwinner-a10.h | 5 +++++ pc-bios/aw-script.bin | Bin 0 -> 50188 bytes 4 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 pc-bios/aw-script.bin
hw/arm/allwinner-a10.c +18 -0
@@ -18,6 +18,7 @@#include "hw/sysbus.h" #include "hw/devices.h" #include "hw/arm/allwinner-a10.h" +#include "hw/loader.h" static void aw_a10_init (Object *obj) {
@@ -33,6 +34,23 @@ static void aw_a10_init(Object *obj)qdev_set_parent_bus (DEVICE (&s->timer),sysbus_get_default ()); } +void aw_a10_load_script (const char *s) +{ +char *file_name; +int file_size; + + file_name =qemu_find_file (QEMU_FILE_TYPE_BIOS , s); + file_size =get_image_size (file_name); +if (file_size <0 ) { +error_report ("%s size is wrong\n" ,AW_CONFIG_SCRIPT ); +return ; + } +if (load_image_targphys (file_name,AW_SCRIPT_ADDR , file_size) <0 ) { +error_report ("can't load %s\n" ,AW_CONFIG_SCRIPT ); +return ; + } +} +static void aw_a10_realize (DeviceState *dev,Error **errp) {AwA10State *s =AW_A10 (dev);
hw/arm/cubieboard.c +2 -0
@@ -48,6 +48,8 @@ static void cubieboard_init(QEMUMachineInitArgs *args)memory_region_add_subregion (get_system_memory (),AW_A10_SDRAM_BASE , &s->sdram); +aw_a10_load_script (AW_CONFIG_SCRIPT ); + cubieboard_binfo.ram_size = args->ram_size; cubieboard_binfo.kernel_filename = args->kernel_filename; cubieboard_binfo.kernel_cmdline = args->kernel_cmdline;
include/hw/arm/allwinner-a10.h +5 -0
@@ -17,6 +17,9 @@#define AW_A10_SDRAM_BASE 0x40000000 +#define AW_CONFIG_SCRIPT "aw-script.bin" +#define AW_SCRIPT_ADDR 0x43000000 +#define TYPE_AW_A10 "allwinner-a10"#define AW_A10 (obj) OBJECT_CHECK(AwA10State, (obj), TYPE_AW_A10)
@@ -31,5 +34,7 @@ typedef struct AwA10State { AwA10PICState intc; } AwA10State; +void aw_a10_load_script (const char *s); +#define ALLWINNER_H_ #endif
pc-bios/aw-script.bin new file binary +0 -0
Signature · 1 line
1.7.2.5
Quoted 9 lines · liguang
sunxi-linux kernel parse config script
to do hardware configurationsSigned-off-by liguang <[email protected]>--- hw/arm/allwinner-a10.c | 18 ++++++++++++++++++ hw/arm/cubieboard.c | 2 ++ include/hw/arm/allwinner-a10.h | 5 +++++ pc-bios/aw-script.bin | Bin 0 -> 50188 bytes
What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid.
thanks
-- PMM
Quoted 12 lines · Peter Maydell
Quoted 10 lines · liguang
sunxi-linux kernel parse config script
to do hardware configurationsSigned-off-by liguang<[email protected]>--- hw/arm/allwinner-a10.c | 18 ++++++++++++++++++ hw/arm/cubieboard.c | 2 ++ include/hw/arm/allwinner-a10.h | 5 +++++ pc-bios/aw-script.bin | Bin 0 -> 50188 bytes
Quoted 4 lines
What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid.
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
[card0_boot_para]card_ctrl = 0card_high_speed = 1card_line = 4sdc_d1 = port:PF00<2><1><default><default>sdc_d0 = port:PF01<2><1><default><default>sdc_clk = port:PF02<2><1><default><default>sdc_cmd = port:PF03<2><1><default><default>sdc_d3 = port:PF04<2><1><default><default>sdc_d2 = port:PF05<2><1><default><default>
[card2_boot_para]card_ctrl = 2card_high_speed = 1card_line = 4sdc_cmd = port:PC06<3><1><default><default>sdc_clk = port:PC07<3><1><default><default>sdc_d0 = port:PC08<3><1><default><default>sdc_d1 = port:PC09<3><1><default><default>sdc_d2 = port:PC10<3><1><default><default>sdc_d3 = port:PC11<3><1><default><default>
[twi_para]twi_port = 0twi_scl = port:PB00<2><default><default><default>twi_sda = port:PB01<2><default><default><default>
[uart_para]uart_debug_port = 0uart_debug_tx = port:PB22<2><1><default><default>uart_debug_rx = port:PB23<2><1><default><default>
....
Quoted 26 lines · Li Guang
Quoted 15 lines · Peter Maydell
Quoted 11 lines · liguang
sunxi-linux kernel parse config script
to do hardware configurationsSigned-off-by liguang<[email protected]>--- hw/arm/allwinner-a10.c | 18 ++++++++++++++++++ hw/arm/cubieboard.c | 2 ++ include/hw/arm/allwinner-a10.h | 5 +++++ pc-bios/aw-script.bin | Bin 0 -> 50188 bytesQuoted 4 lines
What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid.
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
Quoted 10 lines
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>
So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
thanks
-- PMM
Quoted 39 lines · Peter Maydell
Quoted 26 lines · Li Guang
Quoted 14 lines · Peter Maydell
Quoted 11 lines · liguang
sunxi-linux kernel parse config script
to do hardware configurationsSigned-off-by liguang<[email protected]>--- hw/arm/allwinner-a10.c | 18 ++++++++++++++++++ hw/arm/cubieboard.c | 2 ++ include/hw/arm/allwinner-a10.h | 5 +++++ pc-bios/aw-script.bin | Bin 0 -> 50188 bytesQuoted 5 lines
What is this? You can't just stick a 50K binary into the tree with no explanation, I'm afraid.
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
Quoted 11 lines
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>
Quoted 4 lines
So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
it's generally in /boot, bootloader will load it into ram address 0x43000000, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used.
Thanks and Merry Christmas!
Li Guang
Quoted 19 lines · Li Guang
Quoted 18 lines · Peter Maydell
Quoted 15 lines · Li Guang
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>
Quoted 8 lines
Quoted 2 lines
So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
it's generally in /boot, bootloader will load it into ram address
0x43000000, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used.
Weird. Why isn't this just using devicetree? I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it...
Who provides this file? The board manufacturer? Where's the source? How do you create the blob? What license are the sources under?
thanks
-- PMM
Quoted 26 lines · Peter Maydell
Quoted 23 lines · Li Guang
Quoted 21 lines · Peter Maydell
Quoted 4 lines · Li Guang
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
Quoted 12 lines
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
Quoted 8 lines
Quoted 6 lines
it's generally in /boot, bootloader will load it into ram address
0x43000000, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used.Weird. Why isn't this just using devicetree?
don't know the exactly reason linux-sunxi community do this(actually, the script parsing code mostly wrote by engineer from Allwinner).
Quoted 8 lines
I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it...
Who provides this file? The board manufacturer? Where's the source? How do you create the blob? What license are the sources under?
the file will vary for different board,
we can created by our-self,
just write the formatted text script, and
transform it to binary by a tool,
refer to:
http://linux-sunxi.org/Sunxi-tools
Thanks!
Hi,
Quoted 26 lines · Li Guang
Quoted 25 lines · Peter Maydell
Quoted 24 lines · Li Guang
Quoted 16 lines · Peter Maydell
Quoted 4 lines · Li Guang
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
Quoted 11 lines
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>Quoted 2 lines
So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
it's generally in /boot, bootloader will load it into ram address
0x43000000, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used.
Quoted 5 lines
Quoted 1 line
Weird. Why isn't this just using devicetree?
don't know the exactly reason linux-sunxi community do
this(actually, the script parsing code mostly wrote by engineer from Allwinner).
I'm one of the linux-sunxi developers, the only reason we've this fex file abomination, is because we've inherited it from the android-allwinner sources.
Currently most of the linux-sunxi developers are no longer focusing on the 3.4 android/allwinner derived sources we maintain. They are currently in a "good enough for everyday use" state.
So now most of us are focusing on getting *proper* sunxi SoC support upstream. This is using device-tree. Currently we've working timers, interrupt-controller, uarts, mmc, sata, nic (both 100mbit and Gbit variants), ehci controller and builtin rtc support with upstream kernels. Which I believe likely covers everything the qemu emulation offers atm. For those interested, see:
https://github.com/linux-sunxi/linux-sunxi/commits/sunxi-devel
And the mailinglist reports about progress in that branch.
From the linux-sunxi pov fex files are a legacy thing which will go away in the future.
Regards,
Hans
Quoted 3 lines · Hans de Goede
I'm one of the linux-sunxi developers, the only reason we've this fex file abomination, is because we've inherited it from the android-allwinner sources.
Thanks for the clarification; I suspected that might be the case.
Quoted 14 lines
Currently most of the linux-sunxi developers are no longer focusing on the 3.4 android/allwinner derived sources we maintain. They are currently in a "good enough for everyday use" state.
So now most of us are focusing on getting *proper* sunxi SoC support upstream. This is using device-tree. Currently we've working timers, interrupt-controller, uarts, mmc, sata, nic (both 100mbit and Gbit variants), ehci controller and builtin rtc support with upstream kernels. Which I believe likely covers everything the qemu emulation offers atm. For those interested, see:
https://github.com/linux-sunxi/linux-sunxi/commits/sunxi-devel
Quoted 4 lines
And the mailinglist reports about progress in that branch.
From the linux-sunxi pov fex files are a legacy thing which will go away in the future.
Given that, my preference would be to not support fex file loading in QEMU.
thanks
-- PMM
Quoted 23 lines · Peter Maydell
Quoted 4 lines · Hans de Goede
I'm one of the linux-sunxi developers, the only reason we've this fex file abomination, is because we've inherited it from the android-allwinner sources.
Thanks for the clarification; I suspected that might be the case.
Quoted 14 lines
Currently most of the linux-sunxi developers are no longer focusing on the 3.4 android/allwinner derived sources we maintain. They are currently in a "good enough for everyday use" state.
So now most of us are focusing on getting *proper* sunxi SoC support upstream. This is using device-tree. Currently we've working timers, interrupt-controller, uarts, mmc, sata, nic (both 100mbit and Gbit variants), ehci controller and builtin rtc support with upstream kernels. Which I believe likely covers everything the qemu emulation offers atm. For those interested, see:
https://github.com/linux-sunxi/linux-sunxi/commits/sunxi-devel
Quoted 10 lines
Quoted 5 lines
And the mailinglist reports about progress in that branch.
From the linux-sunxi pov fex files are a legacy thing which
will go away in the future.Given that, my preference would be to not support fex file loading in QEMU.
that means we don't care legacy script which already be used in most of cases?
Quoted 28 lines · Li Guang
Quoted 27 lines · Peter Maydell
Quoted 3 lines · Hans de Goede
I'm one of the linux-sunxi developers, the only reason we've this fex file abomination, is because we've inherited it from the android-allwinner sources.
Thanks for the clarification; I suspected that might be the case.
Quoted 19 lines
Currently most of the linux-sunxi developers are no longer focusing on the 3.4 android/allwinner derived sources we maintain. They are currently in a "good enough for everyday use" state.
So now most of us are focusing on getting *proper* sunxi SoC support upstream. This is using device-tree. Currently we've working timers, interrupt-controller, uarts, mmc, sata, nic (both 100mbit and Gbit variants), ehci controller and builtin rtc support with upstream kernels. Which I believe likely covers everything the qemu emulation offers atm. For those interested, see:
https://github.com/linux-sunxi/linux-sunxi/commits/sunxi-develAnd the mailinglist reports about progress in that branch.
From the linux-sunxi pov fex files are a legacy thing which
will go away in the future.
Quoted 5 lines
Quoted 2 lines
Given that, my preference would be to not support fex file loading in QEMU.
that means we don't care legacy script which already be used in most of cases?
If you care about the legacy case I think it would be nicer to support it the same way the hardware does: implement the flash or ROM which on the real hardware has the boot loader in it and then just have a mode where we run the guest firmware and boot the kernel off SD card or similar.
I don't think we should be adding hacks which neither
(a) are part of implementing emulation of the hardware nor (b) are needed to boot upstream kernels.
thanks
-- PMM
Quoted 42 lines · Li Guang
Quoted 27 lines · Peter Maydell
Quoted 5 lines · Hans de Goede
I'm one of the linux-sunxi developers, the only reason we've this fex file abomination, is because we've inherited it from the android-allwinner sources.
Thanks for the clarification; I suspected that might be the case.
Quoted 15 lines
Currently most of the linux-sunxi developers are no longer focusing on the 3.4 android/allwinner derived sources we maintain. They are currently in a "good enough for everyday use" state.
So now most of us are focusing on getting *proper* sunxi SoC support upstream. This is using device-tree. Currently we've working timers, interrupt-controller, uarts, mmc, sata, nic (both 100mbit and Gbit variants), ehci controller and builtin rtc support with upstream kernels. Which I believe likely covers everything the qemu emulation offers atm. For those interested, see:
https://github.com/linux-sunxi/linux-sunxi/commits/sunxi-develQuoted 11 lines
Quoted 5 lines
And the mailinglist reports about progress in that branch.
From the linux-sunxi pov fex files are a legacy thing which
will go away in the future.Given that, my preference would be to not support fex file loading in QEMU.
Quoted 3 lines
that means we don't care legacy script which already be used in most of cases?
Your bootstrap process is just "blob this file at this address" which to me is legitimate generic functionality. If you implement arbitrary file blobbing on Cmd line there are many applications across all archs and plats. and you fex case can be done without any allwinnerisms in tree.
I have use cases for this myself (mainly for emulating handoff in AMP systems - two guests).
Regards
Peter
Quoted 2 lines
Quoted 4 lines · Peter Crosthwaite
Your bootstrap process is just "blob this file at this address" which to me is legitimate generic functionality. If you implement arbitrary file blobbing on Cmd line there are many applications across all archs and plats. and you fex case can be done without any allwinnerisms in tree.
If you want to propose something for generic target file load that's cross architecture and platform I have no inherent objection to that.
thanks
-- PMM
Quoted 29 lines · Peter Maydell
Quoted 19 lines · Li Guang
Quoted 18 lines · Peter Maydell
Quoted 15 lines · Li Guang
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>Quoted 8 lines
Quoted 2 lines
So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
it's generally in /boot, bootloader will load it into ram address
0x43000000, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used.
Quoted 4 lines
Weird. Why isn't this just using devicetree? I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it...
Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)? I toyed with the Idea of a bootloader as a device a while back, which would allow you to implement multiple bootloaders unaware of each other, with arbitrary command line args:
http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg00858.html
That patch demonstrates creating a bootloader as a QOM object. Its ancient, so the style is way out of date, but the idea is still there.
So you could use the ARM linux loader as is, then blob your firmware in on the side something like:
qemu-system-arm -device blob-loader,addr=0x43000000,file=/path/to/blob -kernel ...
I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU.
Regards,
Peter
Quoted 7 lines
Who provides this file? The board manufacturer? Where's the source? How do you create the blob? What license are the sources under?
thanks
-- PMM
Quoted 48 lines · Peter Crosthwaite
Quoted 32 lines · Peter Maydell
Quoted 24 lines · Li Guang
Quoted 18 lines · Peter Maydell
Quoted 4 lines · Li Guang
it's the approach sunxi-linux kernel config hardware, the binary is actually a transformed text script, and context of script is like:
Quoted 12 lines
[
card0_boot_para]card_ctrl= 0card_high_speed= 1card_line= 4sdc_d1= port:PF00<2><1><default><default>sdc_d0= port:PF01<2><1><default><default>sdc_clk= port:PF02<2><1><default><default>sdc_cmd= port:PF03<2><1><default><default>sdc_d3= port:PF04<2><1><default><default>sdc_d2= port:PF05<2><1><default><default>Quoted 3 lines
So what sets this up on real hardware? Is this part of a firmware blob? Is it in ROM or flash?
Quoted 6 lines
it's generally in /boot, bootloader will load it into ram address
0x43000000, kernel will find it at this fixed address, and parse it, learn the hardware related configuration, mostly property of devices, and GPIOes used.Quoted 5 lines
Weird. Why isn't this just using devicetree? I'd rather not have to add support to QEMU's bootloader for weird things like this if I can avoid it...
Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)? I toyed with the Idea of a bootloader as a device a while back, which would allow you to implement multiple bootloaders unaware of each other, with arbitrary command line args:
http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg00858.html
Quoted 10 lines
That patch demonstrates creating a bootloader as a QOM object. Its ancient, so the style is way out of date, but the idea is still there.
So you could use the ARM linux loader as is, then blob your firmware in on the side something like:
qemu-system-arm -device blob-loader,addr=0x43000000,file=/path/to/blob -kernel ...
that's a good option.
Quoted 3 lines
I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU.
Yes, I would like to keep it outside of QEMU, what's about directly add an abstract device called "blob"? and the device has it's properties like path, address...
Quoted 2 lines · Peter Crosthwaite
Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)?
Well, we do already have that (see -machine firmware=whatever), but...
Quoted 2 lines
I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU.
...it's much easier to keep the blob outside QEMU because otherwise it has to have a git submodule and be built somehow and is generally a bit of a faff.
Is this FEX stuff actually supported by the upstream Linux kernel? Googling mostly produced a bunch of stuff from a mid-year flamewar. I definitely don't think we should add any special support for it in QEMU if it's just some random thing that isn't going to be upstreamed.
thanks
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 3 lines · Peter Crosthwaite
Can you just provide a generic solution to the "blob some random data into RAM" problem (If one doesn't exist already)?
Well, we do already have that (see -machine firmware=whatever), but...
Yes, right.
Quoted 13 lines
Quoted 3 lines
I think your binary file here can then just be treated as any other binary boot product and kept outside of QEMU.
...it's much easier to keep the blob outside QEMU because otherwise it has to have a git submodule and be built somehow and is generally a bit of a faff.
Is this FEX stuff actually supported by the upstream Linux kernel? Googling mostly produced a bunch of stuff from a mid-year flamewar. I definitely don't think we should add any special support for it in QEMU if it's just some random thing that isn't going to be upstreamed.
OK, I will use firmware=script.bin option,
thanks!