* [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 @ 2008-10-13 8:22 Thomas Petazzoni 2008-10-13 8:22 ` [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform Thomas Petazzoni ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Thomas Petazzoni @ 2008-10-13 8:22 UTC (permalink / raw) To: qemu-devel; +Cc: michael Hi, This patchset contains the third version of the patches required to add flash support to the ARM Versatile platforms. Compared to v2, the changes are : * Drop the patch that changes the flash write buffer size, since it has been merged in SVN ; * Add a patch updating the documentation to mention the presence of Flash emulation in the ARM Versatile platforms ; * Modify the behaviour of -kernel/-pflash options according to feedback made by Paul Brook. Now, if both a -kernel and a -pflash options are given, Qemu boots from the kernel. If only a -pflash option is passed, Qemu boots from the flash. If none of them are specified, vl/main.c handles the error. Please consider these patches for integration in the SVN. Thanks a lot ! Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform 2008-10-13 8:22 [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni @ 2008-10-13 8:22 ` Thomas Petazzoni 2008-10-13 20:35 ` Cedric Hombourger 2008-10-13 8:22 ` [Qemu-devel] [patch 2/2] Mention flash emulation in Versatile documentation Thomas Petazzoni 2008-10-20 8:11 ` [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni 2 siblings, 1 reply; 8+ messages in thread From: Thomas Petazzoni @ 2008-10-13 8:22 UTC (permalink / raw) To: qemu-devel; +Cc: Thomas Petazzoni, michael [-- Attachment #1: versatilepb-add-flash-support --] [-- Type: text/plain, Size: 4114 bytes --] This patch adds the emulation of the 64 MB Intel Flash present at address 0x34000000 on the ARM Versatile PB platform, with a 256 KB sector size. This flash emulation is enabled using the -pflash option. If a -pflash option is present but no -kernel option has been specified, Qemu starts execution at the flash starting address. If a -kernel option has been specified together with a -pflash option, then Qemu normally boots from the kernel (but the flash is still emulated, of course). The case where neither -kernel nor -pflash have been specified is already catched by the Qemu main function : if (!linux_boot && net_boot == 0 && !machine->nodisk_ok && nb_drives_opt == 0) help(1); Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- hw/versatilepb.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) Index: qemu/hw/versatilepb.c =================================================================== --- qemu.orig/hw/versatilepb.c +++ qemu/hw/versatilepb.c @@ -15,6 +15,7 @@ #include "sysemu.h" #include "pci.h" #include "boards.h" +#include "flash.h" /* Primary interrupt controller. */ @@ -159,6 +160,10 @@ static struct arm_boot_info versatile_binfo; +#define VERSATILE_FLASH_ADDR 0x34000000 +#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024) +#define VERSATILE_FLASH_SECT_SIZE (256 * 1024) + static void versatile_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, @@ -174,6 +179,7 @@ int n; int done_smc = 0; int index; + int hasflash = 0; if (!cpu_model) cpu_model = "arm926"; @@ -184,7 +190,8 @@ } /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ - cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); + cpu_register_physical_memory(0, ram_size, + qemu_ram_alloc(ram_size) | IO_MEM_RAM); arm_sysctl_init(0x10000000, 0x41007004); pic = arm_pic_init_cpu(env); @@ -249,6 +256,21 @@ /* Add PL031 Real Time Clock. */ pl031_init(0x101e8000,pic[10]); + index = drive_get_index(IF_PFLASH, 0, 0); + if (index != -1) { + if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, + qemu_ram_alloc(VERSATILE_FLASH_SIZE), + drives_table[index].bdrv, + VERSATILE_FLASH_SECT_SIZE, + VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE, + 4, 0, 0, 0, 0)) { + fprintf(stderr, "qemu: error registering flash memory.\n"); + exit(1); + } + + hasflash = 1; + } + /* Memory map for Versatile/PB: */ /* 0x10000000 System registers. */ /* 0x10001000 PCI controller config registers. */ @@ -285,12 +307,17 @@ /* 0x101f3000 UART2. */ /* 0x101f4000 SSPI. */ - versatile_binfo.ram_size = ram_size; - versatile_binfo.kernel_filename = kernel_filename; - versatile_binfo.kernel_cmdline = kernel_cmdline; - versatile_binfo.initrd_filename = initrd_filename; - versatile_binfo.board_id = board_id; - arm_load_kernel(env, &versatile_binfo); + if (kernel_filename) { + versatile_binfo.ram_size = ram_size; + versatile_binfo.kernel_filename = kernel_filename; + versatile_binfo.kernel_cmdline = kernel_cmdline; + versatile_binfo.initrd_filename = initrd_filename; + versatile_binfo.board_id = board_id; + arm_load_kernel(env, &versatile_binfo); + } + else if (hasflash) { + env->regs[15] = VERSATILE_FLASH_ADDR; + } } static void vpb_init(ram_addr_t ram_size, int vga_ram_size, @@ -321,6 +348,7 @@ .init = vpb_init, .use_scsi = 1, .max_cpus = 1, + .ram_require = VERSATILE_FLASH_SIZE, }; QEMUMachine versatileab_machine = { @@ -329,4 +357,5 @@ .init = vab_init, .use_scsi = 1, .max_cpus = 1, + .ram_require = VERSATILE_FLASH_SIZE, }; -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform 2008-10-13 8:22 ` [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform Thomas Petazzoni @ 2008-10-13 20:35 ` Cedric Hombourger 2008-10-13 22:01 ` Thomas Petazzoni 0 siblings, 1 reply; 8+ messages in thread From: Cedric Hombourger @ 2008-10-13 20:35 UTC (permalink / raw) To: qemu-devel; +Cc: Thomas Petazzoni, michael Hi Thomas, Well done! I have had a modified qemu for sometime now to do this as well but never got to the point where the Linux kernel could mount the root file-system from flash. I quickly gave a try to your patch using the latest svn and it seems to be the same (i.e. u-boot ok, kernel gets loaded from flash to memory and then boots but it fails to mount a root file-system). I have started to look into this but not yet deep enough to understand what is going on.... my kernel seems to be reading zeros instead of the cramfs magic number while the address that I am reading from seems to be correct. Is this something that you have tested and works for you? I will be happy to help if you also have issues. Cedric 2008/10/13 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>: > This patch adds the emulation of the 64 MB Intel Flash present at > address 0x34000000 on the ARM Versatile PB platform, with a 256 KB > sector size. This flash emulation is enabled using the -pflash > option. > > If a -pflash option is present but no -kernel option has been > specified, Qemu starts execution at the flash starting address. If a > -kernel option has been specified together with a -pflash option, then > Qemu normally boots from the kernel (but the flash is still emulated, > of course). > > The case where neither -kernel nor -pflash have been specified is > already catched by the Qemu main function : > > if (!linux_boot && net_boot == 0 && > !machine->nodisk_ok && nb_drives_opt == 0) > help(1); > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > --- > hw/versatilepb.c | 43 ++++++++++++++++++++++++++++++++++++------- > 1 file changed, 36 insertions(+), 7 deletions(-) > > Index: qemu/hw/versatilepb.c > =================================================================== > --- qemu.orig/hw/versatilepb.c > +++ qemu/hw/versatilepb.c > @@ -15,6 +15,7 @@ > #include "sysemu.h" > #include "pci.h" > #include "boards.h" > +#include "flash.h" > > /* Primary interrupt controller. */ > > @@ -159,6 +160,10 @@ > > static struct arm_boot_info versatile_binfo; > > +#define VERSATILE_FLASH_ADDR 0x34000000 > +#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024) > +#define VERSATILE_FLASH_SECT_SIZE (256 * 1024) > + > static void versatile_init(ram_addr_t ram_size, int vga_ram_size, > const char *boot_device, DisplayState *ds, > const char *kernel_filename, const char *kernel_cmdline, > @@ -174,6 +179,7 @@ > int n; > int done_smc = 0; > int index; > + int hasflash = 0; > > if (!cpu_model) > cpu_model = "arm926"; > @@ -184,7 +190,8 @@ > } > /* ??? RAM should repeat to fill physical memory space. */ > /* SDRAM at address zero. */ > - cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); > + cpu_register_physical_memory(0, ram_size, > + qemu_ram_alloc(ram_size) | IO_MEM_RAM); > > arm_sysctl_init(0x10000000, 0x41007004); > pic = arm_pic_init_cpu(env); > @@ -249,6 +256,21 @@ > /* Add PL031 Real Time Clock. */ > pl031_init(0x101e8000,pic[10]); > > + index = drive_get_index(IF_PFLASH, 0, 0); > + if (index != -1) { > + if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, > + qemu_ram_alloc(VERSATILE_FLASH_SIZE), > + drives_table[index].bdrv, > + VERSATILE_FLASH_SECT_SIZE, > + VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE, > + 4, 0, 0, 0, 0)) { > + fprintf(stderr, "qemu: error registering flash memory.\n"); > + exit(1); > + } > + > + hasflash = 1; > + } > + > /* Memory map for Versatile/PB: */ > /* 0x10000000 System registers. */ > /* 0x10001000 PCI controller config registers. */ > @@ -285,12 +307,17 @@ > /* 0x101f3000 UART2. */ > /* 0x101f4000 SSPI. */ > > - versatile_binfo.ram_size = ram_size; > - versatile_binfo.kernel_filename = kernel_filename; > - versatile_binfo.kernel_cmdline = kernel_cmdline; > - versatile_binfo.initrd_filename = initrd_filename; > - versatile_binfo.board_id = board_id; > - arm_load_kernel(env, &versatile_binfo); > + if (kernel_filename) { > + versatile_binfo.ram_size = ram_size; > + versatile_binfo.kernel_filename = kernel_filename; > + versatile_binfo.kernel_cmdline = kernel_cmdline; > + versatile_binfo.initrd_filename = initrd_filename; > + versatile_binfo.board_id = board_id; > + arm_load_kernel(env, &versatile_binfo); > + } > + else if (hasflash) { > + env->regs[15] = VERSATILE_FLASH_ADDR; > + } > } > > static void vpb_init(ram_addr_t ram_size, int vga_ram_size, > @@ -321,6 +348,7 @@ > .init = vpb_init, > .use_scsi = 1, > .max_cpus = 1, > + .ram_require = VERSATILE_FLASH_SIZE, > }; > > QEMUMachine versatileab_machine = { > @@ -329,4 +357,5 @@ > .init = vab_init, > .use_scsi = 1, > .max_cpus = 1, > + .ram_require = VERSATILE_FLASH_SIZE, > }; > > -- > Thomas Petazzoni, Free Electrons > Kernel, drivers and embedded Linux development, > consulting, training and support. > http://free-electrons.com > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform 2008-10-13 20:35 ` Cedric Hombourger @ 2008-10-13 22:01 ` Thomas Petazzoni 0 siblings, 0 replies; 8+ messages in thread From: Thomas Petazzoni @ 2008-10-13 22:01 UTC (permalink / raw) To: Cedric Hombourger; +Cc: qemu-devel, michael Hi Cédric ! Le Mon, 13 Oct 2008 22:35:54 +0200, "Cedric Hombourger" <chombourger@gmail.com> a écrit : > Well done! I have had a modified qemu for sometime now to do this as > well but never got to the point where the Linux kernel could mount the > root file-system from flash. I quickly gave a try to your patch using > the latest svn and it seems to be the same (i.e. u-boot ok, kernel > gets loaded from flash to memory and then boots but it fails to mount > a root file-system). I have started to look into this but not yet deep > enough to understand what is going on.... my kernel seems to be > reading zeros instead of the cramfs magic number while the address > that I am reading from seems to be correct. Is this something that you > have tested and works for you? I will be happy to help if you also > have issues. So far, I've only tested : * Starting U-Boot from the Flash ; * Loading the kernel to RAM from TFTP in U-Boot ; * Saving the kernel to Flash ; * Saving the U-Boot environment to Flash ; * Booting the kernel from Flash ; * Having the kernel detect the Flash partitions ; * Erase one block of Flash from Linux using flash_erase. I haven't tested yet mounting root filesystems from Flash, so it's possible that it doesn't work completely. I'll try to have a look at this during this week. Thanks for testing and thanks for your feedback ! Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [patch 2/2] Mention flash emulation in Versatile documentation 2008-10-13 8:22 [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni 2008-10-13 8:22 ` [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform Thomas Petazzoni @ 2008-10-13 8:22 ` Thomas Petazzoni 2008-10-20 8:11 ` [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni 2 siblings, 0 replies; 8+ messages in thread From: Thomas Petazzoni @ 2008-10-13 8:22 UTC (permalink / raw) To: qemu-devel; +Cc: Thomas Petazzoni, michael [-- Attachment #1: mention-flash-emulation-in-versatilepb-doc --] [-- Type: text/plain, Size: 710 bytes --] In the Qemu documentation, mention the fact the flash emulation is available for the Versatile platform. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- qemu-doc.texi | 2 ++ 1 file changed, 2 insertions(+) Index: qemu/qemu-doc.texi =================================================================== --- qemu.orig/qemu-doc.texi +++ qemu/qemu-doc.texi @@ -2528,6 +2528,8 @@ @item PL190 Vectored Interrupt Controller @item +Intel-compatible Flash memory (64 megabytes) +@item Four PL011 UARTs @item SMC 91c111 Ethernet adapter -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 2008-10-13 8:22 [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni 2008-10-13 8:22 ` [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform Thomas Petazzoni 2008-10-13 8:22 ` [Qemu-devel] [patch 2/2] Mention flash emulation in Versatile documentation Thomas Petazzoni @ 2008-10-20 8:11 ` Thomas Petazzoni 2008-10-20 11:26 ` Jean-Christophe PLAGNIOL-VILLARD 2 siblings, 1 reply; 8+ messages in thread From: Thomas Petazzoni @ 2008-10-20 8:11 UTC (permalink / raw) To: qemu-devel Le Mon, 13 Oct 2008 10:22:38 +0200, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> a écrit : > Please consider these patches for integration in the SVN. Unless I missed it, these patches do not seem to have been merged in Qemu. Is there any further comments that should be adressed before they can be merged ? Thanks, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 2008-10-20 8:11 ` [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni @ 2008-10-20 11:26 ` Jean-Christophe PLAGNIOL-VILLARD 2008-10-21 15:08 ` Thomas Petazzoni 0 siblings, 1 reply; 8+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-10-20 11:26 UTC (permalink / raw) To: qemu-devel On 10:11 Mon 20 Oct , Thomas Petazzoni wrote: > Le Mon, 13 Oct 2008 10:22:38 +0200, > Thomas Petazzoni <thomas.petazzoni@free-electrons.com> a écrit : > > > Please consider these patches for integration in the SVN. > > Unless I missed it, these patches do not seem to have been merged > in Qemu. Is there any further comments that should be adressed before > they can be merged ? IMHO we need to check that you U-Boot patch could run on a real hardware before modify qemu. As I sais before we need to be reflect the hardware at maximun Best Regards, J. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 2008-10-20 11:26 ` Jean-Christophe PLAGNIOL-VILLARD @ 2008-10-21 15:08 ` Thomas Petazzoni 0 siblings, 0 replies; 8+ messages in thread From: Thomas Petazzoni @ 2008-10-21 15:08 UTC (permalink / raw) To: qemu-devel; +Cc: Michael, Jean-Christophe PLAGNIOL-VILLARD, Opdenacker Hi, Thanks for your feedback ! Le Mon, 20 Oct 2008 13:26:29 +0200, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> a écrit : > IMHO we need to check that you U-Boot patch could run on a real > hardware before modify qemu. As I sais before we need to be reflect > the hardware at maximun My U-Boot patch is only secondary: the flash emulation can simply be used by the Linux kernel, for example. In my U-Boot patch, the only thing related to the flash is the switch from a Versatile-specific flash driver to the generic CFI driver. The rest of the modifications have nothing to do with the flash, they are just hacks/workarounds to get U-Boot to run under Qemu and are not related in any way with this patch (network driver things and timing things). These issues should be worked out as a separate Qemu patch if we really want Qemu to run an unmodified U-Boot for the Versatile platform, but IMO, that shouldn't prevent the flash emulation from being merged in Qemu. Sincerly, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-10-21 15:08 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-13 8:22 [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni 2008-10-13 8:22 ` [Qemu-devel] [patch 1/2] Add Flash support to the Versatile PB platform Thomas Petazzoni 2008-10-13 20:35 ` Cedric Hombourger 2008-10-13 22:01 ` Thomas Petazzoni 2008-10-13 8:22 ` [Qemu-devel] [patch 2/2] Mention flash emulation in Versatile documentation Thomas Petazzoni 2008-10-20 8:11 ` [Qemu-devel] [patch 0/2] Add Flash support to the ARM Versatile platforms, v3 Thomas Petazzoni 2008-10-20 11:26 ` Jean-Christophe PLAGNIOL-VILLARD 2008-10-21 15:08 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).