From patchwork Thu Oct 5 21:49:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rages X-Patchwork-Id: 23365 Received: (qmail 94915 invoked by alias); 5 Oct 2017 21:49:05 -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 94319 invoked by uid 89); 5 Oct 2017 21:49:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-21.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=flash, H*c:alternative, Hayward, hayward X-HELO: mail-pf0-f180.google.com Received: from mail-pf0-f180.google.com (HELO mail-pf0-f180.google.com) (209.85.192.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Oct 2017 21:49:03 +0000 Received: by mail-pf0-f180.google.com with SMTP id d2so5388770pfh.0 for ; Thu, 05 Oct 2017 14:49:03 -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:from:date:message-id:subject:to; bh=Oh/nOIX9PXa9ujKuIuS+wqmD4EqBT9bub07Ilj+12/U=; b=eFSphYMPEWRG7erhSSzo6/p2+n45g/C3BpEzESoX8XQwpDypRZt4FZDrkDbfn5UVFm Q5K59W322oYuFrnE3D5jQMQ6mXnDmvWJlOyM815Ek27/Zsx9//qxFBPS1LE/YXOSiDIE 5Im4r2jA4ROyn7AsDtOOrdyEkDb/LRlRnmfk+w1pbGo25IbLfGM9U/BCsy+K35IeO8kI j/vt5w77ipnxvI6vXNPDjUdYk6M+fHaten+G9CtBeLw/zbnYAfq8acjMYLWqxK/5YIF4 ih9TW0ubb2GpC/Z8YIjBIX4Ot9utikKcVLhg29lE+75ClbsYewX8stzIv06tbqIZZ0Op /N5w== X-Gm-Message-State: AMCzsaW4Lx76MwxfeSVagemghhvd4FMvLtpyW3JT1vn/yCGomuLahhmm 2ELBpEdu1OlbOGTZ9Bz7WJH8Q9cw7Mnp9yERTfUk X-Google-Smtp-Source: AOwi7QCi+keyPZmri4/AF8pnAQijJgUx3mGc1IT74QoFtVlTROsPsTHhw8ZkKArU5xCiUFXn/8WdGVHq0bMa8xYynJg= X-Received: by 10.98.155.218 with SMTP id e87mr99117pfk.96.1507240142050; Thu, 05 Oct 2017 14:49:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.180.129 with HTTP; Thu, 5 Oct 2017 14:49:01 -0700 (PDT) From: Mark Rages Date: Thu, 5 Oct 2017 15:49:01 -0600 Message-ID: Subject: Flash memory size not aligned to address To: gdb-patches@sourceware.org X-IsSubscribed: yes 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; }