All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: "mar.krzeminski" <mar.krzeminski@gmail.com>,
	Peter Maydell <peter.maydell@linaro.org>
Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Andrew Jeffery <andrew@aj.id.au>,
	Marcin Krzeminski <marcin.krzeminski@nokia.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-2.9 24/30] aspeed: use first SPI flash as a boot ROM
Date: Mon, 5 Dec 2016 10:36:39 +0100	[thread overview]
Message-ID: <f28b693f-dade-b338-cc86-b5e85f8b1675@kaod.org> (raw)
In-Reply-To: <4e2db842-7ff6-d7e7-c96c-26ce9c563c83@gmail.com>

Hello Marcin,

On 12/04/2016 06:00 PM, mar.krzeminski wrote:
> Hi Cedric,
> 
> it looks like good idea for now to handle boot from flash.
> As I understand you are trying to omit bootrom code in Qemu model?

I suppose you mean handling a romd memory region under the m25p80 
object ? 

> This could lead you to some hacks in device models (eg SMC).

I haven't had to, yet. 
 
> W dniu 29.11.2016 o 16:44, Cédric Le Goater pisze:
>> Fill a ROM region with the flash content to support U-Boot. This is a
>> little hacky but until we can boot from a MMIO region, it seems
>> difficult to do anything else.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> Reviewed-by: Joel Stanley <joel@jms.id.au>
>> Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
>> ---
>>  hw/arm/aspeed.c | 41 +++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 41 insertions(+)
>>
>> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
>> index 40c13838fb2d..a92c2f1c362b 100644
>> --- a/hw/arm/aspeed.c
>> +++ b/hw/arm/aspeed.c
>> @@ -20,6 +20,8 @@
>>  #include "qemu/log.h"
>>  #include "sysemu/block-backend.h"
>>  #include "sysemu/blockdev.h"
>> +#include "hw/loader.h"
>> +#include "qemu/error-report.h"
>>  
>>  static struct arm_boot_info aspeed_board_binfo = {
>>      .board_id = -1, /* device-tree-only board */
>> @@ -104,6 +106,28 @@ static const AspeedBoardConfig aspeed_boards[] = {
>>      },
>>  };
>>  
>> +#define FIRMWARE_ADDR 0x0
>> +
>> +static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
>> +                           Error **errp)
>> +{
>> +    BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
>> +    uint8_t *storage;
>> +
>> +    if (rom_size > blk_getlength(blk)) {
>> +        rom_size = blk_getlength(blk);
>> +    }
> I was not able to attach smaller file as m25p80 storage.

yes that's most probably because m25p80_realize() does : 

       if (blk_pread(s->blk, 0, s->storage, s->size) != s->size) {
            error_setg(errp, "failed to read the initial flash content");
            return;
        }

my bad. May be, we could relax a bit the test and allow smaller block 
backends ? 


>> +
>> +    storage = g_new0(uint8_t, rom_size);
>> +    if (blk_pread(blk, 0, storage, rom_size) < 0) {
>> +        error_setg(errp, "failed to read the initial flash content");
>> +        return;
>> +    }
>> +
>> +    rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr);
>> +    g_free(storage);
>> +}
>> +
>>  static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
>>                                        Error **errp)
>>  {
>> @@ -135,6 +159,7 @@ static void aspeed_board_init(MachineState *machine,
>>  {
>>      AspeedBoardState *bmc;
>>      AspeedSoCClass *sc;
>> +    DriveInfo *drive0 = drive_get(IF_MTD, 0, 0);
>>  
>>      bmc = g_new0(AspeedBoardState, 1);
>>      object_initialize(&bmc->soc, (sizeof(bmc->soc)), cfg->soc_name);
>> @@ -168,6 +193,22 @@ static void aspeed_board_init(MachineState *machine,
>>      aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort);
>>      aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort);
>>  
>> +    /* Install first FMC flash content as a boot rom. */
>> +    if (drive0) {
>> +        AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0];
>> +        MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
>> +
>> +        /*
>> +         * create a ROM region using the default mapping window size of
>> +         * the flash module.
>> +         */
>> +        memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
>> +                               fl->size, &error_abort);
>> +        memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
>> +                                    boot_rom);
>> +        write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
>
> Is it possible that fl->size will be bigger than segment size?
>
> I think max_size here should be segment size in smc.

I am not sure what you mean by "segment" ? 

fl->size holds the default mapping window size on the AHB bus of the 
flash chip CS0. The size can be changed by the guest using the segment 
address registers but for CS0 this should be "autoconfigured" by HW.

Here, we are just using the default from the specs but we could go a 
little further in the model and setup the mapping window size of CS0 
using the block backend size, and set up the segment registers accordingly.
There are some checks to be done. It might be a little complex.

Thanks,

C. 


> Thanks,
> Marcin
>> +    }
>> +
>>      aspeed_board_binfo.kernel_filename = machine->kernel_filename;
>>      aspeed_board_binfo.initrd_filename = machine->initrd_filename;
>>      aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
> 

  reply	other threads:[~2016-12-05  9:37 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 15:43 [Qemu-devel] [PATCH for-2.9 00/30] Aspeed SoC fixes and model improvements Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 01/30] target-arm: Add VBAR support to ARM1176 CPUs Cédric Le Goater
2016-12-14 15:43   ` Peter Maydell
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 02/30] m25p80: add support for the mx66l1g45g Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 03/30] aspeed: QOMify the CPU object and attach it to the SoC Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 04/30] aspeed: remove cannot_destroy_with_object_finalize_yet Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 05/30] aspeed: attach the second SPI controller object to the SoC Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 06/30] aspeed: extend the board configuration with flash models Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 07/30] aspeed: add support for the romulus-bmc board Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 08/30] aspeed: add a memory region for SRAM Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 09/30] aspeed: add the definitions for the AST2400 A1 SoC Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 10/30] aspeed: change SoC revision of the palmetto-bmc machine Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 11/30] aspeed/scu: fix SCU region size Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 12/30] aspeed/smc: improve segment register support Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 13/30] aspeed/smc: set the number of flash modules for the FMC controller Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 14/30] aspeed/smc: rework the prototype of the AspeedSMCFlash helper routines Cédric Le Goater
2016-12-14 17:09   ` Peter Maydell
2016-12-15 13:38     ` Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 15/30] aspeed/smc: introduce a aspeed_smc_flash_update_cs() helper Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 16/30] aspeed/smc: autostrap CE0/1 configuration Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 17/30] aspeed/smc: handle SPI flash Command mode Cédric Le Goater
2016-12-04 16:31   ` mar.krzeminski
2016-12-05 14:07     ` Cédric Le Goater
2016-12-05 15:33       ` mar.krzeminski
2017-01-02 15:56         ` Cédric Le Goater
2017-01-02 17:33           ` mar.krzeminski
2017-01-02 18:02             ` Cédric Le Goater
2017-01-02 18:21               ` mar.krzeminski
2017-01-03 10:50                 ` Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 18/30] aspeed/smc: extend tests for " Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 19/30] aspeed/smc: unfold the AspeedSMCController array Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 20/30] aspeed/smc: add a 'sdram_base' property Cédric Le Goater
2016-11-29 15:43 ` [Qemu-devel] [PATCH for-2.9 21/30] aspeed/smc: add support for DMAs Cédric Le Goater
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 22/30] aspeed/smc: handle dummy bytes when doing fast reads Cédric Le Goater
2016-12-04 16:46   ` mar.krzeminski
2016-12-05 14:14     ` Cédric Le Goater
2016-12-05 15:12       ` mar.krzeminski
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 23/30] aspeed/smc: adjust the size of the register region Cédric Le Goater
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 24/30] aspeed: use first SPI flash as a boot ROM Cédric Le Goater
2016-12-04 17:00   ` mar.krzeminski
2016-12-05  9:36     ` Cédric Le Goater [this message]
2016-12-05  9:57       ` Marcin Krzemiński
2016-12-05 14:53         ` Cédric Le Goater
2016-12-05 15:09           ` mar.krzeminski
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 25/30] block: add a model option for MTD devices Cédric Le Goater
2016-11-29 16:06   ` Cédric Le Goater
2016-11-29 17:30   ` Cédric Le Goater
2016-11-29 18:08     ` Kevin Wolf
2016-11-30 15:09       ` Cédric Le Goater
2016-11-30 15:55         ` Kevin Wolf
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 26/30] aspeed/smc: use flash model option Cédric Le Goater
2016-11-30 16:26   ` Cédric Le Goater
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 27/30] wdt: Add Aspeed watchdog device model Cédric Le Goater
2017-01-16 17:14   ` Cédric Le Goater
2016-11-29 15:44 ` [Qemu-devel] [PATCH for-2.9 28/30] aspeed: add a watchdog controller Cédric Le Goater
2016-11-30  2:01   ` Andrew Jeffery
2016-11-29 16:07 ` [Qemu-devel] [PATCH for-2.9 29/30] aspeed/scu: add a aspeed_scu_get_clk() helper Cédric Le Goater
2016-11-29 16:07   ` [Qemu-devel] [PATCH for-2.9 30/30] wdt: aspeed: use scu to get clock freq Cédric Le Goater
2016-11-29 19:17     ` Cédric Le Goater
2016-11-29 19:16   ` [Qemu-devel] [PATCH for-2.9 29/30] aspeed/scu: add a aspeed_scu_get_clk() helper Cédric Le Goater
2016-11-29 17:26 ` Cédric Le Goater
2016-11-29 17:26   ` [Qemu-devel] [PATCH for-2.9 30/30] wdt: aspeed: use scu to get clock freq Cédric Le Goater
2016-12-14 17:12 ` [Qemu-devel] [PATCH for-2.9 00/30] Aspeed SoC fixes and model improvements Peter Maydell
2016-12-14 17:51   ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f28b693f-dade-b338-cc86-b5e85f8b1675@kaod.org \
    --to=clg@kaod.org \
    --cc=andrew@aj.id.au \
    --cc=crosthwaite.peter@gmail.com \
    --cc=mar.krzeminski@gmail.com \
    --cc=marcin.krzeminski@nokia.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.