From patchwork Sat Oct 7 18:36:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rages X-Patchwork-Id: 23390 Received: (qmail 58327 invoked by alias); 7 Oct 2017 18:36:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 58316 invoked by uid 89); 7 Oct 2017 18:36:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Flash, D*free.fr, Addr, H*c:alternative X-HELO: mail-pf0-f175.google.com Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Oct 2017 18:36:55 +0000 Received: by mail-pf0-f175.google.com with SMTP id m28so6034191pfi.11 for ; Sat, 07 Oct 2017 11:36:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=VsVSNA+Nq44R8f3Xc10iiYrTzfdGqWZNy8qq45jqITc=; b=goNK1Cn9rx0y39hWsA8D8ywke/uBxc9LYqaUl1TLV340EWgEwoOkDqccCW67gA+rld 9FYgJ/3N9qbWoguxBqUfvzJGy1izsH1wnTKsoQJzzs3EnsXJrfHnBIrHwmXmMrfz4AV+ aatNqykFoU3IVuDmoLypPTw4neU/O+2eR321Rh9McSKJvYNt4yEj9GUUYU4G/dFbMLVs IVA6XAqOwLGPupOZz2plvP+IwcvOOFdePikls1MVfCgboOodrMMGxI/2rbbbUId6h3S+ SN/VdurDHoj5oEGtYnNSo1zp2Tde7gtAjxi6YCUbbQwJqHDd2IEZHl1XzSaqHv6YlxcH Fw6Q== X-Gm-Message-State: AMCzsaUx8JqdotgYsKcRFuN5hC6V/tfO2wt/2kM8x6H1FPAensfvf0h8 IeLkf9jV+YVnWrKASjq/VdCSQVyEABHHwt3nbg== X-Google-Smtp-Source: AOwi7QChzYDJkmx9BsuYgE1dEYic7PvYgK6WOoXum1NHdEZSE1ilJN0SXB14Taz6iUDvQb63H/Y4sAu1+t6I/0k1XF0= X-Received: by 10.99.119.206 with SMTP id s197mr5124442pgc.83.1507401413735; Sat, 07 Oct 2017 11:36:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.180.129 with HTTP; Sat, 7 Oct 2017 11:36:53 -0700 (PDT) Received: by 10.100.180.129 with HTTP; Sat, 7 Oct 2017 11:36:53 -0700 (PDT) In-Reply-To: References: From: Mark Rages Date: Sat, 7 Oct 2017 12:36:53 -0600 Message-ID: Subject: [PATCH] Re: Flash memory size not aligned to address To: gdb-patches@sourceware.org X-IsSubscribed: yes Who can review my patch? Regards, Mark On Oct 5, 2017 3:49 PM, "Mark Rages" wrote: The Nordic nRF52 memory map, reported from black magic probe: Num Enb Low Addr High Addr Attrs 0 y 0x00000000 0x00080000 flash blocksize 0x1000 nocache 1 y 0x10001000 0x10001210 flash blocksize 0x210 nocache 2 y 0x20000000 0x20010000 rw nocache The region at 0x10001000 is "UICR" and it is a section of flash that is erased all at once. Notice the odd size: 0x210 is the size of the region defined in the datasheet. But because the block size was listed as 0x210, gdb was insisting on issuing two erase commands divisible by 0x210, starting below 0x10001000. This patch fixes it by doing the alignment computation from the start of the region, not from address 0: /* Given the list of memory requests to be WRITTEN, this function diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d8d5772..d2dc194 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-10-05 Mark Rages + + * target-memory.c (block_boundaries): Fix for block address not + aligned on block size. + 2017-10-05 Tristan Gingold * MAINTAINERS (Misc): Update my email address. @@ -6962,7 +6967,7 @@ 2017-05-08 Alan Hayward - * mn10300-linux-tdep.c (am33_supply_gregset_method): Use + * mn10300-linux-tdep.c (am33_supply_gregset_method): Use regcache->raw_supply_zeroed. 2017-05-06 Sergio Durigan Junior diff --git a/gdb/target-memory.c b/gdb/target-memory.c index 1c8faa8..4651200 100644 --- a/gdb/target-memory.c +++ b/gdb/target-memory.c @@ -138,14 +138,18 @@ block_boundaries (CORE_ADDR address, CORE_ADDR *begin, CORE_ADDR *end) { struct mem_region *region; unsigned blocksize; + CORE_ADDR address_in_region; region = lookup_mem_region (address); gdb_assert (region->attrib.mode == MEM_FLASH); blocksize = region->attrib.blocksize; + + address_in_region = address - region->lo; + if (begin) - *begin = address / blocksize * blocksize; + *begin = region->lo + address_in_region / blocksize * blocksize; if (end) - *end = (address + blocksize - 1) / blocksize * blocksize; + *end = region->lo + (address_in_region + blocksize - 1) / blocksize * blocksize; }